问题
Ok, what I want to do seems like an extremely core part of the facebook apps experience, and yet I can't find any decent examples. I just want to generate an 'apprequest' to notify another user when something of interest has happened when a friend used the app. I'm using Java and RestFB, and have tried this code:
FacebookType publishMessageResponse =
fbClient.publish("me/apprequests", FacebookType.class,
Parameter.with("message", "RestFB test"));
and have tried replacing "me" with a user id, which results in an OAuthException: (#100) Invalid parameter: Unknown error. The facebook documentation describes this PHP example:
$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);
But just like everything else I'm seeing, isn't this just sending something to the current user, ie myself? What's the point of that? If anyone's done this in Java I'd love to hear from you :)
回答1:
I got a unit test working with restfb doing exactly what you describe.
I posted as an answer to another question here: Facebook: send an app invitation
来源:https://stackoverflow.com/questions/7309950/posting-app-generated-apprequest-to-other-facebook-users-in-java