2011年10月17日 星期一

[Facebook] Search Place by Latitude & Longitude

<?php

require './src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId' => '2249678xxxxx',
  'secret' => '2374aebcxxxxxxxxxxx',
));


// Get User ID
$user = $facebook->getUser();

$lat = '25.066667';
$lng = '121.583333';


$location = $facebook->api('/search?type=place&center=' . $lat . ',' . $lng . '&distance=1000');   // distance => Search Range

print_r($location);

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}


// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}

?>

沒有留言:

張貼留言