我正在编写一个脚本来自动从目录中检索 .png 文件并将其发布到我的Facebook页面,其中包含一堆主题标签作为其message.function
publish($filename, $card_type, $message){
$filename = "http://www.mywebsite.com/sandboxassets/img/burrocards/" . $card_type . "/" . $filename;
echo 'publish this file: ' . $filename;
// retrieve fb credentials
$config_vals = parse_ini_file("../../../nicethings.ini");
$appid = $config_vals['fbappid'];
$token = $config_vals['fbtoken'];
$secret = $config_vals['fbsecret'];
// initialize Facebook class using your own Facebook App credentials
$fb = new Facebook\Facebook([
'app_id' => $appid,
'app_secret' => $secret,
'default_graph_version' => 'v2.8',
]);
// define your POST parameters (replace with your own values)
$params = array(
"access_token" => $token,
"message" => $message,
"link" => "http://www.mywebsite.com",
"picture" => $filename
);
// post to Facebook
try {
$post = $fb->post('/MyPage/feed', $params);
$post = $post->getGraphNode()->asArray();
echo 'Successfully posted to Facebook';
} catch(Exception $e) { echo $e->getMessage(); }
}
此脚本运行正常,但我不想将发布的图片链接到任何网站。我只需将其作为未链接的图像发布。但当我从该功能中删除以下一行时,Facebook拒绝了这个电话,说我必须为图片帖子定义一个链接:
"link" => "http://www.mywebsite.com",
有什么方法可以实现我想要的目标吗?必须有,因为我经常手动将图像发布到我的页面,而不必将其链接到任何内容。