截至目前,我正在使用tagged_places
来获取用户最近的位置。这将以此格式返回,
[1] => stdClass Object
(
[id] => 10000000000000018
[created_time] => 2014-05-30T21:41:11+0000
[place] => stdClass Object
(
[id] => 164380000000000000
[location] => stdClass Object
(
[city] => New YOrk
[country] => United States
[latitude] => 25.628888888
[longitude] => -44.000000000346
[state] => OK
[street] => 444 S Mart Ave
[zip] => 74224-5022
)
[name] => Bob's Pub
)
这很棒但是......
在Facebook中,我注意到在发布状态时单击邮箱上的位置图标时,会在您周围生成显示已经或已经检查过多少人的位置。
因此,当您使用您的位置创建帖子时,可能会说tulsa downtown 26 people were here
。
在发布您的位置时,有没有办法让Feed中显示的人数相同?
这似乎不是朋友,只是一个人的总数。
谢谢!
这是我目前的代码。
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// include required files form Facebook SDK
// added in v4.0.5
require_once( 'facebook/src/Facebook/FacebookHttpable.php' );
require_once( 'facebook/src/Facebook/FacebookCurl.php' );
require_once( 'facebook/src/Facebook/FacebookCurlHttpClient.php' );
require_once( 'facebook/src/Facebook/FacebookSession.php' );
require_once( 'facebook/src/Facebook/FacebookRedirectLoginHelper.php' );
require_once( 'facebook/src/Facebook/FacebookRequest.php' );
require_once( 'facebook/src/Facebook/FacebookResponse.php' );
require_once( 'facebook/src/Facebook/FacebookSDKException.php' );
require_once( 'facebook/src/Facebook/FacebookRequestException.php' );
require_once( 'facebook/src/Facebook/FacebookOtherException.php' );
require_once( 'facebook/src/Facebook/FacebookAuthorizationException.php' );
require_once( 'facebook/src/Facebook/GraphObject.php' );
require_once( 'facebook/src/Facebook/GraphSessionInfo.php' );
use Facebook\FacebookHttpable;
use Facebook\FacebookCurl;
use Facebook\FacebookCurlHttpClient;
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookOtherException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphSessionInfo;
// start session
session_start();
// init app with app id and secret
FacebookSession::setDefaultApplication( 'foo','foo' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper( 'http://www.placonweb.com/' );
// see if a existing session exists
if ( isset( $_SESSION ) && isset( $_SESSION['fb_token'] ) ) {
// create new session from saved access_token
$session = new FacebookSession( $_SESSION['fb_token'] );
// validate the access_token to make sure it's still valid
try {
if ( !$session->validate() ) {
$session = null;
}
} catch ( Exception $e ) {
// catch any exceptions
$session = null;
}
} else {
// no session exists
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
// handle this better in production code
print_r( $ex );
} catch( Exception $ex ) {
// When validation fails or other local issues
// handle this better in production code
print_r( $ex );
}
}
// see if we have a session
if ( isset( $session ) ) {
// save the session
$_SESSION['fb_token'] = $session->getToken();
// create a session using saved token or the new one we generated at login
$session = new FacebookSession( $session->getToken() );
// graph api request for user data with response
$graphObject = (new FacebookRequest( $session, 'GET', '/me?fields=id,first_name,last_name,tagged_places' ))->execute()->getGraphObject()->asArray();
}
?>
答案 0 :(得分:0)
您需要访问page
api,该API将返回该位置的checkins
个数。
https://developers.facebook.com/docs/graph-api/reference/v2.0/page/