gpt4 book ai didi

php - 向 Facebook 页面关注者发送私有(private)消息 PHP SDK

转载 作者:行者123 更新时间:2023-12-02 02:58:34 25 4
gpt4 key购买 nike

我几天前一直在使用 Facebook PHP SDK。我已经阅读了 Facebook 文档 here如果您有用户的电话号码,则可以向用户发送私有(private)消息,但这似乎不起作用。

这是我的代码:

     $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);

输出:

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] => )

我也尝试过根据文档使用收件人的 Facebook ID,但它仍然不起作用。

最佳答案

我知道这是一个老问题,但我来到这里,这可以帮助其他人进行研究。

Facebook does not allow to a bot to write to an user if the user did not interact with the bot on the Messanger app.

您可以找到可能交互的详尽列表 here

关于php - 向 Facebook 页面关注者发送私有(private)消息 PHP SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47865661/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com