duanjing1276 2017-12-18 09:45
浏览 74

发送私人消息给Facebook页面追随者PHP SDK

I have been working with Facebook PHP SDK a couple of days ago. And I have read in the Facebook Docs here that it is possible to send a private messages to users if you have their phone number but this does not seem to work.

Here is my Code:

     $fb = new Facebook\Facebook([
      'app_id' => 'xxxxxxxxxxxxx',
      'app_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
      'default_graph_version' => 'v2.3',
      // . . .
      ]);
    $post = [
  'access_token' => $_SESSION['page_access_token'],
  'message'      =>  
  [
    'text' => 'Hello, wadup?!!!'
  ],
  'recipient' => [
    'id' => '+1(0)0000000000'
  ]
];

$response = $fb->post('https://graph.facebook.com/v2.6/me/messages?', $post, $_SESSION['page_access_token']);
print_r($response);

The output:

Facebook\FacebookResponse Object ( [httpStatusCode:protected] => 200 [headers:protected] => Array ( [x-page-usage] => {"call_count":1,"total_cputime":1,"total_time":1} [Strict-Transport-Security] => max-age=15552000; preload [x-fb-trace-id] => CQO0hjDHbf0 [x-fb-rev] => 3535263 [Expires] => Sat, 01 Jan 2000 00:00:00 GMT [Content-Type] => application/json; charset=UTF-8 [facebook-api-version] => v2.11 [Cache-Control] => private, no-cache, no-store, must-revalidate [Pragma] => no-cache [Access-Control-Allow-Origin] => * [Vary] => Accept-Encoding [X-FB-Debug] => WYq6KntFxQ/uTEK8B4tsvF+UfAXzsTtpm4yJcVxkrXkxTPo04yx/ITqLTe8Ho7k+tLhzC87eNojGjjgKXaGnIg== [Date] => Mon, 18 Dec 2017 09:43:11 GMT [Connection] => keep-alive [Content-Length] => 82 ) [body:protected] => {"id":"1157989877575188","url":"https:\/\/graph.facebook.com\/v2.6\/me\/messages"} [decodedBody:protected] => Array ( [id] => 1157989877575188 [url] => https://graph.facebook.com/v2.6/me/messages ) [request:protected] => Facebook\FacebookRequest Object ( [app:protected] => Facebook\FacebookApp Object ( [id:protected] => 1709050269133889 [secret:protected] => 1ceb6a6e1e4419f2799e699ebae2808e ) [accessToken:protected] => EAAYSX0Yx7EEBAH11ZAg7RWx60038nfYK1V1gOzqnu2NG0riV9DWiMRIJ9tZBfQwxqo92OaXx6uzhDZBn3xji8LXBP3mChJpbrCKpRLniUob9YlE1wZA3cnMSFIjA8eBjEaAUMJRfYvOBGfP7hIqMzNDU7fOPQOyXLFlPZAbdMZAQZDZD [method:protected] => POST [endpoint:protected] => https://graph.facebook.com/v2.6/me/messages [headers:protected] => Array ( [Content-Type] => application/x-www-form-urlencoded ) [params:protected] => Array ( [message] => Array ( [text] => Hello, wadup?!!! ) [recipient] => Array ( [id] => 100002192125690 ) ) [files:protected] => Array ( ) [eTag:protected] => [graphVersion:protected] => v2.3 ) [thrownException:protected] => )

I have also tried using the recipients Facebook ID according to the documentation, but it doesn't work still.

  • 写回答

1条回答 默认 最新

  • qq_33821686 2020-07-15 14:33
    关注

    如何开发出一个通知Facebook用户的php?

    评论

报告相同问题?

悬赏问题

  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型