Twitter Geo

Users tweet from all over the world. These methods allow you to attach location data to tweets and discover tweets & locations.

Figure 1a. Instantiate Geo
$geo = eden('twitter')->geo('[TWITTER_KEY]', '[TWITTER_SECRET]', $_SESSION['access_token'], $_SESSION['access_secret']);
Figure 1b. Usage: Creating a Place
$geo->setAddress($address)				//optional
  ->setCallback($callBack)				//optional
  ->createPlace($name, $contained, $token, $lat, $long);
Figure 1c. Usage: Get GEO Code
$geo->setAccuracy($accuracy)		//optional
  ->setGranularity($granularity)	//optional
  ->setMax($max)					//optional
  ->setCallback($callBack)			//optional
  ->getGeocode($lat, $long);
Figure 1d. Usage: Get a Particular Place
$place = $geo->getPlace($id);
Figure 1e. Usage: Get Similar Places
$similar = $geo
	->setContained($contained)		//optional
	->setAddress($address)			//optional
	->setCallback($callback)		//optional
	->getSimilarPlaces($lat, $long, $name);
Figure 1f. Usage: Searching for a Place
$search = $geo
	->setLat($lat)					//optional
	->setLong($long)				//optional
	->setInput($input)				//optional
	->setAccuracy($accuracy)		//optional
	->setGranularity($granularity)	//optional
	->setMax($max)					//optional
	->setContained($contained)		//optional
	->setAddress($address)			//optional
	->setCallback($callback)		//optional
	->search();
Figure 1g. Geo Methods
Method Arguments Returns Description
$geo->createPlace($name, $contained, $token, $latitude, $longtitude);
  1. string
  2. - The name a place
  3. string
  4. - The place_id within which the new place can be found
  5. string
  6. - The token found in the response from geo/similar_places.
  7. float|integer
  8. float|integer
array Creates a new place object at the given latitude and longitude.
$geo->getGeocode($lat, $long);
  1. float|integer
  2. float|integer
array Given a latitude and a longitude, searches for up to 20 places that can be used as a place_id when updating a status
$geo->getPlace($id);
  1. int
  2. - place ID
array Returns all the information about a known place.
$geo->getSimilarPlaces($latitude, $longtitude, $name);
  1. float|int
  2. float|int
  3. string
  4. - The name of the place
array Locates places near the given coordinates which are similar in name.
$geo->search($query = NULL);
  1. string|null
array Search for places that can be attached to a statuses/update.
$geo->setAccuracy($accuracy);
  1. string
Eden_Twitter_Geo This is the minimal granularity of place types to return and must be one of: poi, neighborhood, city, admin or country. If no granularity is provided for the request neighborhood is assumed. Setting this to city, for example, will find places which have a type of city, admin or country
$geo->setAddress($address);
  1. string
Eden_Twitter_Geo This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted.
$geo->setCallback($callback);
  1. string
Eden_Twitter_Geo If supplied, the response will use the JSONP format with a callback of the given name.
$geo->setContained($contained);
  1. string
Eden_Twitter_Geo This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found. Specify a place_id. For example, to scope all results to places within "San Francisco, CA USA", you would specify a place_id of "5a110d312052166f"
$geo->setGranularity($granularity);
  1. string
Eden_Twitter_Geo This is the minimal granularity of place types to return and must be one of: poi, neighborhood, city, admin or country. If no granularity is provided for the request neighborhood is assumed. Setting this to city, for example, will find places which have a type of city, admin or country.
$geo->setIp($ip);
  1. string
Eden_Twitter_Geo An IP address. Used when attempting to fix geolocation based off of the user's IP address.
$geo->setLatitude($latitude);
  1. int|float
Eden_Twitter_Geo 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.
$geo->setLongtitude($longtitude);
  1. int|float
Eden_Twitter_Geo 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.
$geo->setMaxResults($maxResults);
  1. integer
Eden_Twitter_Geo A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.

© 2012 Openovate Labs. All rights reserved.