TijsVerkoyen\Twitter\Twitter::geoReverseGeoCode PHP Метод

geoReverseGeoCode() публичный Метод

This request is an informative call and will deliver generalized results about geography.
public geoReverseGeoCode ( float $lat, float $long, string[optional] $accuracy = null, string[optional] $granularity = null, int[optional] $maxResults = null ) : array
$lat float The latitude to search around. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding long parameter.
$long float The longitude to search around. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding lat parameter.
$accuracy string[optional]
$granularity string[optional]
$maxResults int[optional]
Результат array
    public function geoReverseGeoCode($lat, $long, $accuracy = null, $granularity = null, $maxResults = null)
    {
        // build parameters
        $parameters['lat'] = (double) $lat;
        $parameters['long'] = (double) $long;
        if ($accuracy != null) {
            $parameters['accuracy'] = (string) $accuracy;
        }
        if ($granularity != null) {
            $parameters['granularity'] = (string) $granularity;
        }
        if ($maxResults != null) {
            $parameters['max_results'] = (int) $maxResults;
        }
        // make the call
        return $this->doCall('geo/reverse_geocode.json', $parameters);
    }

Usage Example

Пример #1
0
 /**
  * Tests Twitter->geoReverseGeoCode()
  */
 public function testGeoReverseGeoCode()
 {
     $response = $this->twitter->geoReverseGeoCode(37.7821120598956, -122.400612831116);
     $this->assertArrayHasKey('result', $response);
     $this->assertArrayHasKey('places', $response['result']);
     foreach ($response['result']['places'] as $row) {
         $this->assertArrayHasKey('name', $row);
         $this->assertArrayHasKey('contained_within', $row);
         $this->assertArrayHasKey('place_type', $row);
         $this->assertArrayHasKey('country_code', $row);
         $this->assertArrayHasKey('url', $row);
         $this->assertArrayHasKey('bounding_box', $row);
         $this->assertArrayHasKey('attributes', $row);
         $this->assertArrayHasKey('id', $row);
         $this->assertArrayHasKey('full_name', $row);
         $this->assertArrayHasKey('country', $row);
     }
     $this->assertArrayHasKey('type', $response['query']);
     $this->assertArrayHasKey('params', $response['query']);
     $this->assertArrayHasKey('coordinates', $response['query']['params']);
     $this->assertArrayHasKey('accuracy', $response['query']['params']);
     $this->assertArrayHasKey('granularity', $response['query']['params']);
     $this->assertArrayHasKey('url', $response['query']);
 }
Twitter