您如何使用 FB API 4.0 执行基本查询以在 post 上获得赞?
How do you perform a basic query to get the likes on a post using FB API 4.0?
我正在尝试执行基本查询以在 post https://www.facebook.com/explosm/photos/a.427422470475.216607.67400590475/10153591161400476/?type=1&theater 上获得点赞
我的代码没有任何错误,但也没有返回任何值。
如何使用 FB API 4.0 执行基本查询以在 post 上获得赞?
<!DOCTYPE html>
<html>
<body>
<head>
<?php
session_start();
// added in v4.0.0
require_once 'facebook-php-sdk-v4/autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
FacebookSession::setDefaultApplication( '1111111111111','22222222222222222222222' );
$helper = new FacebookRedirectLoginHelper('http://favd.co/fbauthtest.php' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me/likes' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
// print data
echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';
} else {
// show login url
echo '<a href="' . $helper->getLoginUrl() . '">Login</a>';
}
/*
$request = new FacebookRequest(
$session,
'GET',
//'/me/likes'
'/fql?q=SELECT%10153591170640476%20FROM%20like%20WHERE%20object_id=427422470475%20%LIMIT=1000'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
*/
?>
</head>
</body>
</html>
我建议你使用
/10153591170640476/likes
相反。在 Graph Explorer 中尝试:
见
我正在尝试执行基本查询以在 post https://www.facebook.com/explosm/photos/a.427422470475.216607.67400590475/10153591161400476/?type=1&theater 上获得点赞 我的代码没有任何错误,但也没有返回任何值。
如何使用 FB API 4.0 执行基本查询以在 post 上获得赞?
<!DOCTYPE html>
<html>
<body>
<head>
<?php
session_start();
// added in v4.0.0
require_once 'facebook-php-sdk-v4/autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
FacebookSession::setDefaultApplication( '1111111111111','22222222222222222222222' );
$helper = new FacebookRedirectLoginHelper('http://favd.co/fbauthtest.php' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me/likes' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
// print data
echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';
} else {
// show login url
echo '<a href="' . $helper->getLoginUrl() . '">Login</a>';
}
/*
$request = new FacebookRequest(
$session,
'GET',
//'/me/likes'
'/fql?q=SELECT%10153591170640476%20FROM%20like%20WHERE%20object_id=427422470475%20%LIMIT=1000'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
*/
?>
</head>
</body>
</html>
我建议你使用
/10153591170640476/likes
相反。在 Graph Explorer 中尝试:
见