Advertisement
iamdangavin

Geolocation for Instagram

Jun 28th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 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.                 print_r ($data->data);
  5.                     foreach($data->data as $item):
  6.                    
  7.                     $lat = (!empty($item->location->latitude))?$item->location->latitude:null; // Caches latitude as $lat
  8.                     $lon = (!empty($item->location->longitude))?$item->location->longitude:null; // Caches longitude as $lon
  9.                     $location = (!empty($item->location->name))?$item->location->name:null;
  10.                     $id = (!empty($item->location->id))?$item->location->id:null;
  11.                    
  12.                         if(isset($instance['hashtag'], $item->caption->text)):
  13.                             $image_title = $item->user->username.': &quot;'.filter_var($item->caption->text, FILTER_SANITIZE_STRING).'&quot;';
  14.                         elseif(isset($instance['hashtag']) && !isset($item->caption->text)):
  15.                             $image_title = "instagram by ".$item->user->username;
  16.                         else:
  17.                             $image_title = filter_var($item->caption->text, FILTER_SANITIZE_STRING);
  18.                         endif;
  19.                         $images[] = array(
  20.                             "title" => $image_title,
  21.                             "id" => htmlentities($id),
  22.                             "location" => htmlentities($location),
  23.                             "lat" => htmlentities($lat),
  24.                             "lon" => htmlentities($lon),
  25.                             "url" => $item->link,
  26.                             "date" => htmlentities(date("F j, Y, g:i a", $item->caption->created_time)),
  27.                             "image_small" => $item->images->thumbnail->url,
  28.                             "image_middle" => $item->images->low_resolution->url,
  29.                             "image_large" => $item->images->standard_resolution->url
  30.                         );
  31.                     endforeach;
  32.                 endif;
  33.             endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement