It would seem that this would be a simple thing to do, but I just can't seem to find anything on how to accomplish this on the Facebook Developer forum, the API nor Google. I'm using the PHP SDK to write a simple app that looks for a certain change regarding the current user (not to seem mysterious, it's just that this part is irrelevant). As soon as thi开发者_运维技巧s change is detected, I want to somehow alert the current user of the change, just not by posting it to the user's wall, this information needs to stay confidential - it needs to stay between the user and the app. According to the Facebook API documentation, notifications are generated automatically - so I have no control over them, and I can't seem to get the Bookmark counter to update automatically either - I have to problem getting it to increment when the user visits the app canvas page and something occurs, but what I want is to alert the user of a certain event without requiring the user to actually visit the app canvas.
I would guide you to the Request dialog page because it's (supposed to be) the right place to look. But as usual something is missing in the documentation.
Anyway, what you are looking for is a application-generated request:
<?php
$app_id = YOUR_APP_ID;
$app_secret = YOUR_APP_SECRET;
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $app_id .
"&client_secret=" . $app_secret .
"&grant_type=client_credentials";
$app_access_token = file_get_contents($token_url);
$user_id = THE_CURRENT_USER_ID;
$apprequest_url ="https://graph.facebook.com/" .
$user_id .
"/apprequests?message=’INSERT_UT8_STRING_MSG’" .
"&data='INSERT_STRING_DATA'&" .
$app_access_token . "&method=post";
$result = file_get_contents($apprequest_url);
echo("Request id number: ", $result);
?>
Described in a "blog post" instead of the documentation! and can be fount in this document (thanks @Charles).
I'm using the PHP SDK to write a simple app that looks for a certain change regarding the current user (not to seem mysterious, it's just that this part is irrelevant).
Actually, that's not entirely irrelevant, as the Facebook TOS prevents you from doing this in most situations, especially defriending, relationship statuses, etc.
As soon as this change is detected, I want to somehow alert the current user of the change, just not by posting it to the user's wall, this information needs to stay confidential - it needs to stay between the user and the app.
Request their e-mail and send it that way.
精彩评论