Send FB user a notification via App

坚强是说给别人听的谎言 提交于 2019-12-11 05:00:02

问题


I'm getting an App access token via the Facebook API.

$app_id = "ID";
$app_secret = "SECRET";
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=".$app_id."&client_secret=".$app_secret."&grant_type=client_credentials";
$app_token = file_get_contents($token_url);

When $app_token is echoed, the following is displayed

access_token=xxxxxxxxxxxxxxxxxxxxxxxx // access token x'ed out for security.

The "ID" is equal to my application ID (which I'm not silly enough to write). There's a vertical bar that separates the ID from another alphanumeric string.

I'm not very experienced with this aspect of the API, particularly doing what involves App access token rather than user access tokens.

So, when I tried to send a test notification in a php script

$url = "https://graph.facebook.com/".$fb_user_id."/notifications?href=".$url."&".$app_token;
$result = file_get_contents($url);

$result gives me an error message as such:

{"error":{"message":"A user access token is required to request this resource.","type":"OAuthException","code":102}}

回答1:


As indicated on https://developers.facebook.com/docs/concepts/notifications/, you should using HTTP POST requests to send notification to the user of your apps, not HTTP GET requests.



来源:https://stackoverflow.com/questions/15722605/send-fb-user-a-notification-via-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!