1

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}}
4

1 回答 1

2

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.

于 2013-04-16T11:57:27.727 回答