Reputation: 208
i want to send facebook notification to my friend through my app . i have used following notification api through restfb library
facebookClient = new DefaultFacebookClient(vAccessTokenDetails.getVAccessToken());
String app_access_token = facebookClient.obtainAppAccessToken("485626xxxxxx614","d9428570ef5ae82609b6xxxxxxxb").getAccessToken();
publishMessageResponse = facebookClient.publish(post.getVFriendId()+"/notifications?access_token="+app_access_token, FacebookType.class, Parameter.with("template", post.getVMessage()), Parameter.with("href", "http://www.wiinkURL.com")); vPostId = publishMessageResponse.getId();
but i am getting com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: (#15) This method must be called with an app access_token
Upvotes: 0
Views: 839
Reputation: 11
The FacebookClient object should be created using app_access_token instead of access_token.
FacbookClient facebookClientAppAccessToken =
new DefaultFacebookClient( app_access_token );
publishMessageResponse = facebookClientAppAccessToken.publish(..);
Upvotes: 1