有人能帮我使用Graph API向Facebook好友发送消息吗?
我尝试过:
$response = $facebook->call_api("/me/feed", "post", "to=john","message=You have a Test message");
它没有起作用。我手头有用户的访问令牌,但是我对发送过程感到困惑。
有人能帮我使用Graph API向Facebook好友发送消息吗?
我尝试过:
$response = $facebook->call_api("/me/feed", "post", "to=john","message=You have a Test message");
它没有起作用。我手头有用户的访问令牌,但是我对发送过程感到困惑。
你无法通过 Facebook 应用程序发送消息。虽然过去是可以的,但(可预见的?)大量滥用导致了这种能力的撤销。
假设 Alice 是您的用户,并且已经授予您必要的扩展权限,那么您有以下选项:
to
字段 ;) 但是不行,所以它没有被列出来。 - Julio Santos您可以在弹出窗口中打开 发送对话框。
$parameters = array(
'app_id' => $facebook->getAppId(),
'to' => $facebookUserId,
'link' => 'http://google.nl/',
'redirect_uri' => 'http://my.app.url/callback'
);
$url = 'http://www.facebook.com/dialog/send?'.http_build_query($parameters);
echo '<script type="text/javascript">window.open('.json_encode($url).', ...
详细选项请参见:
https://developers.facebook.com/docs/reference/dialogs/send/$attachment = array(
'access_token' => $access_token,
'message' => $msg,
'name' => $name,
'link' => $link,
'description' => $desc,
);
facebook->api('/'.$uesr_id.'/feed', 'POST', $attachment);
技术上说,您可以使用隐私设置进行动态或交叉动态发布,只有动态所有者可以看到该动态,但这并不是向某个人发送消息。
You can use
HTTP POST with
PATH
https://graph.facebook.com/friend_facebook_id/feed
PARAMETER
MESSAGE = your message
ACCESS_TOKEN = your oauth2 access token
您可以发送电子邮件到他们的Facebook邮箱。Facebook邮箱由个人资料昵称+'@facebook.com'组成。该电子邮件将发送到他们的Facebook收件箱中。请注意,Facebook邮箱不接受欺骗性电子邮件。您需要白标域或使用SendGrid。
FB.api('/'+friendID+'/feed', 'post',
{
method: 'feed',
message: messageText,
name: 'write a title here',
caption: 'Put a caption here.',
description: 'Put your description here.',
link: 'https://dev59.com/B3A85IYBdhLWcg3wF_m0',
picture: 'link to the preview thumbnail',
},
function(response) {
if (!response || response.error) {
//alert('Error occured');
} else {
//alert('Post ID: ' + response.id);
}
});
所以这就是使用JavaScript SDK完成的 - PHP方法应该是类似的。
不要使用下面的代码
[facebook dialog:@"feed"
andParams:params
andDelegate:self];
[facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];