简体   繁体   English

如何使用cURL发送通知?

[英]How to send a notification with cURL?

After a lot of researches, I solved all the errors I got trying to send a notification from my app to the current user. 经过大量研究,我解决了尝试从应用程序向当前用户发送通知时遇到的所有错误。 But now, no more errors, but a blank answer. 但是现在,不再有错误,而是一个空白的答案。 I use the following code : 我使用以下代码:

curl_setopt($curl, CURLOPT_URL, "https://graph.facebook.com/me/notifications?access_token=".$facebook->getAccessToken()."&template=Message&http://google.com"); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
$page = curl_exec($curl); 
curl_close($curl); 

I receive this from Graph : {"data":[],"summary":[]} And no new notification... Believing Facebook, I must receive {"success": true}. 我从Graph收到此消息:{“ data”:[],“ summary”:[]}并且没有新的通知...相信Facebook,我必须收到{“ success”:true}。

Any idea ? 任何想法 ? Thanks. 谢谢。

PS : Sorry if my english is bad, I'm French. PS:对不起,如果我的英语不好,我是法语。

You need to set your cURL options to POST this request, but since you have the Facebook PHP SDK installed, why are you directly calling cURL for this instead of using the API? 您需要将cURL选项设置为POST,但是由于已经安装了Facebook PHP SDK,为什么要为此直接调用cURL而不使用API​​?

$result = $facebook->api("/{$user_name_or_id}/notifications/", 'POST', array(
        'template' => 'Message',
       ); 

In order to POST a notification, this must be done from an app that is configured as an "App on Facebook". 为了发布通知,必须从配置为“ Facebook上的应用程序”的应用程序中完成此操作。 It also does not appear to work with me . 它似乎也不适用于me You need to explicitly call a username or id. 您需要显式调用用户名或ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM