我是Facebook API的新手,并试图在网页上获得网页的星级评分,但没有达到目标......
<?php
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
$fb = new \Facebook\Facebook([
'app_id' => '{API_ID_HERE}',
'app_secret' => '{API_SECRET_HERE}',
'default_graph_version' => 'v2.10',
//'default_access_token' => '{ACCESS_TOKEN_HERE}', // optional
]);
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/PAGE_ID_HERE/ratings'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
?>
我不认为它是100%正确但至少尝试连接,但我一直在努力;
未找到“FacebookRequest”类
我用谷歌搜索但没有发现任何有建设性的东西,我有作曲家等但不确定我缺少什么
干杯
更新
我找到了这个错误的解决方案,但没有得到一个没有意义的全新错误......
注意:未定义的变量:第33行的C:\ xampp \ htdocs \ phptests \ php-graph-sdk \ index.php中的会话
警告:parse_url()期望参数1为字符串,数组在第109行的C:\ xampp \ htdocs \ phptests \ php-graph-sdk \ src \ Facebook \ Url \ FacebookUrlManipulator.php中给出
警告:parse_url()期望参数1为字符串,数组在第43行的C:\ xampp \ htdocs \ phptests \ php-graph-sdk \ src \ Facebook \ Url \ FacebookUrlManipulator.php中给出
致命错误:在第41行的C:\ xampp \ htdocs \ phptests \ php-graph-sdk \ index.php中调用未定义的方法Facebook \ FacebookRequest :: execute()
<?php
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
use Facebook\FacebookRequest;
// PHP GRAPH SDK 5.5
function QueryToRetrieveUserThroughID(string $id) {
$newFacebook = new Facebook\Facebook([
'app_id' => '',
'app_secret' => '',
'default_graph_version' => 'v2.5',
]);
$newFacebookApp = $newFacebook->getApp();
$response = $newFacebook->get($id, '');
// or $response = $newFacebook->get($id);
$graphObject = $response->getGraphObject();
}
$request = new FacebookRequest(
$session,
'GET',
'//ratings',
array(
'fields' => 'rating'
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
?>