【发布时间】:2013-02-26 14:07:50
【问题描述】:
谁能帮帮我? 我尝试在我的组中的帐户(我是组的管理员)上发帖。 (如图)
我有两个功能。在我自己的墙上发帖,没有错误。
现在我开始使用群发帖中的第二个功能.. 不幸的是,到目前为止没有成功。
函数 2 给我错误的回复。
我的范围 user_groups,publish_actions,email,read_stream,publish_stream,user_photos,friends_photos,manage_pages
function PostMessage(){
$postString = 'message='.rawurlencode($this->getMessage()).'&uid='.$this->getUId().'&attachment='.urlencode($this->getAttachment()).'&'.$this->getAccessToken();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.facebook.com/method/stream.publish");
curl_setopt($curl, CURLOPT_FAILONERROR, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postString);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
//print_r($response);
curl_close($curl);
}
function PostGroupMessage(){
$postString = 'message='.rawurlencode($this->getMessage()).'&uid='.$this->getUId().'&attachment='.urlencode($this->getAttachment()).'&'.$this->getAccessToken();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://graph.facebook.com/".$this->getGroupId()."/feed"); // Neither group name nor the groups function id
curl_setopt($curl, CURLOPT_FAILONERROR, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postString);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
}
编辑:
这是在我发布运行之前从对象中转储的:
object(fb_send)#1 (6) {
["m_AppId":"fb_send":private]=>
string(15) "xxxx"
["m_SecretId":"fb_send":private]=>
string(32) "xxxx"
["m_UId":"fb_send":private]=>
int(xxxx)
["m_AccessToken":"fb_send":private]=>
string(56) "access_token=xxxx"
["m_Message":"fb_send":private]=>
string(101) "Besuchen Sie www.modelweb24.de - Die neue kostenlose social community für Fotografen und Fotomodelle!"
["m_Attachment":"fb_send":private]=>
string(258) "{"href":"http://www.modelweb24.de","name":"Wir begrüßen ","caption":"","description":"auf www.modelweb24.de","media":[{"type":"image","src":"http://www.modelweb24.de/ow_static/themes/OWD-Nyx/images/logofb.png","href":"http://www.modelweb24.de/"}]}"
}
然后我做 PostGroupMessage() 并且 $response 是 bool(false)。 没有更多错误
编辑 2:
https://graph.facebook.com/180243765369952/feed/?access_token=xxxxx在群墙上给我所有的消息
编辑 3:
我已经发送了参数 ?method=POST,现在我出错了。 我缺少什么权限?
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
【问题讨论】:
-
API 是否有错误?
-
我已经发送了参数 ?method=POST ,现在我出错了。我缺少什么许可? { "error": { "message": "(#200) 用户未授权应用程序执行此操作", "type": "OAuthException", "code": 200 } }
-
您尚未被用户授予 user_groups 和 publish_actions(或 publish_stream)权限 - 您还在
PostMessage()中调用已弃用的 API - 我建议检查当前文档而不是任何示例或示例您正在使用的代码
标签: php facebook facebook-graph-api