我正在一个网站上有超过三个Facebook的页面像按钮。一旦用户点击按钮。首先,我需要认证用户,然后喜欢相应的页面。然而,用户认证工作正常,现在我需要像一个页面。我正在关注Facebook Like Documentation。但是我对文档中提到的{object-id}感到困惑。这是什么object-id以及我如何得到这个?Facebook使用Facebook图形API的按钮
像页面代码:
session_start();
require_once '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('App_ID','App_Secret');
$helper = new FacebookRedirectLoginHelper('http://localhost/fb/like.php');
try {
$session = $helper->getSessionFromRedirect();
} catch(FacebookRequestException $ex) {
// Facebook returns an error
} catch(Exception $ex) {
// validation fails or other local issues
}
if (isset($session)) {
// Get Basic Userinfo
$getUserInfoObj = new FacebookRequest($session, 'GET', '/me');
$getUserInfoProcess = $getUserInfoObj->execute();
$getUserInforesult = $getUserInfoProcess->getGraphObject();
$id = $getUserInforesult->getProperty('id');
// Once Use Logged In Like the respective page
// Like page code
echo '<pre>';print_r($getUserInforesult);exit;
//header("Location: index.php");
} else {
$loginUrl = $helper->getLoginUrl();
header("Location: ".$loginUrl);
}
敢肯定你可以不喜欢使用API – WizKid
你好@WizKid页,谢谢。您可以点击上面提到的文档链接,并阅读*** Publishing ***部分。他们想说什么? –
如果你不相信我,那么只需测试它并证明我错了。 – WizKid