Advertisement
iamdangavin

Get Geolocation for Instagram

Jun 28th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. if(!is_wp_error($response) && $response['response']['code'] < 400 && $response['response']['code'] >= 200):
  2.     $data = json_decode($response['body']);
  3.     if($data->meta->code == 200):
  4.         foreach($data->data as $item):
  5.  
  6.             // Get Lat and Long
  7.             $lat = (isset($item->data->location->latitude))?$item->data->location->latitude:null; // Caches latitude as $lat
  8.                     $lon = (isset($item->data->location->longtitude))?$item->data->location->longtitude:null; // Caches longitude as $lon
  9.  
  10.                     if(isset($instance['hashtag'], $item->caption->text)):
  11.                 $image_title = $item->user->username.': &quot;'.filter_var($item->caption->text, FILTER_SANITIZE_STRING).'&quot;';
  12.             elseif(isset($instance['hashtag']) && !isset($item->caption->text)):
  13.                 $image_title = "instagram by ".$item->user->username;
  14.             else:
  15.                 $image_title = filter_var($item->caption->text, FILTER_SANITIZE_STRING);
  16.             endif;
  17.         $images[] = array(
  18.             "title" => $image_title,
  19.             "lat" => htmlspecialchars($lat),
  20.                     "lon" => htmlspecialchars($lon),
  21.             "image_small" => $item->images->thumbnail->url,
  22.             "image_middle" => $item->images->low_resolution->url,
  23.             "image_large" => $item->images->standard_resolution->url
  24.             );
  25.         endforeach;
  26.     endif;
  27. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement