是否可以通过Facebook GRAPH API发送私人消息?

时间:2014-07-04 10:56:15

标签: facebook

我真的需要一个解决方案。 Facebook消息似乎是"只读"。 我用的是javascript。

f.e。 {conversation-id} / messages?message = {"你好那里"} (不工作)

2 个答案:

答案 0 :(得分:0)

您可以在2015年4月之前使用他们的chat API。之后,its gone

答案 1 :(得分:0)

不,你不能通过Facebook GRAPH API发送私信,你也不能通过FQL这样做,但有一个解决方案:
有一种方法可以将消息发送到用户的主要收件箱,你需要一个完全开源的库(由我)然后:

<?php
require_once('send.message.php'); //requires file
require_once('facebook.php'); //sdk provided by facebook, you need one for tokens and
//all
$config = array('appId' => '1496661733888719' ,'secret'=>'0c959ab2dec71c5a53aab1cd64751223' );
$facebook=new Facebook($config);
if(!$facebook->getUser()){
    $params = array(
  'scope' => 'read_mailbox, xmpp_login',
  'redirect_uri' => 'http://localhost/'
    );
    $url=$facebook->getLoginUrl($params);
    header("location:".$url);
    die();
}
$messageobj=new SendMessage($facebook);

$receiverId=''; // this may either be username or userID, this class takes care of both the //cases
$body='test message';
if($messageobj->sendMessage($body,$receiverId))
{
echo 'message sent';
}else
{
echo 'some error occured';
}
?>

通过这种方式,您可以向用户发送消息,您可以在以下网址获取详细信息:

nishgtm.com/2013/11/facebook-message-api-php/

您还可以在上面的链接中找到指向github页面的链接。这个库非常容易使用。随意通过评论问我任何事情。