我正在努力从我们网站上的 FB 页面发布帖子。我们添加到我们的 FB 页面的每个新帖子和照片也需要在我们的网站上显示。
我有这段代码,但没有按我的需要工作。
require 'php-graph-sdk-5.x/src/Facebook/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => '...',
'app_secret' => '{app-secret}', // don't know where to find app_secret for my page, I've found that just for apps, not pages
'default_graph_version' => 'v2.10'
]);
$access_token = '...'; // generated in developers, but with just for 12 hours, than this token is expired... :-(
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get('me?fields=id,name,feed,data', $access_token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
foreach ($graphNode as $node) {
foreach ($node as $items) {
print_r($items);
// when access token was valid, I got posts from out FB page. But with no images, didn't find how to get add images to this feed...
}
}
所以,我的问题是:
在哪里可以找到 FB 页面的 app-secret?没有那个我无法连接到我的 FB 页面,我想
如何生成永久访问令牌,或者如果不可能,如何以其他方式制作我?
如何将图像(新的、共享的等)添加到我的提要?
谢谢。