I want to get fan page news/feeds without user login and without access token. in this question I found that you don't need any access token. if you have App-ID and App-Secret. This solution works on browser but doesn't on Android app.
Here is my code sample:
new GraphRequest(null,
"https://graph.facebook.com/{group_id}/feed?access_token={app_id}|{app_secret}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
Log.d("Facebook_feed", response.toString());
}
}).executeAsync();
Here my response:
{
Response: responseCode: 400,
graphObject: null,
error: {
HttpStatus: 400,
errorCode: 190,
errorType: OAuthException,
errorMessage: Invalid OAuth access token signature.
}
}
Why this happen?
Related
Using This code for getting event:-
new Request(session,"/{event-id}",null,HttpMethod.GET,new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
System.out.println("Result: " + response.toString());
}
}).executeAsync();
}
});
Permission :---
authButton.setReadPermissions(Arrays.asList("user_location", "user_birthday", "user_likes","user_events","read_stream"));
And it gave me error :----
I/System.outīš Result: {Response: responseCode: 404, graphObject: null, error: {HttpStatus: 404, errorCode: 803, errorType: OAuthException, errorMessage: (#803) Some of the aliases you requested do not exist: {event-id}}, isFromCache:false}
The error message explains it
(#803) Some of the aliases you requested do not exist: {event-id}
new Request(session,"/{event-id}",null,HttpMethod.GET,new Request.Callback()
There should be an actual event ID or at least a variable that holds the value of an event ID.
I am using facebook sdk for login in android app. my code working fine for login facebook in android app. but then i used facebook like action using facebook sdk error is occured. The error is below
{Response: responseCode: 403, graphObject: null, error: {HttpStatus: 403, errorCode: 200, errorType: OAuthException, errorMessage: (#200) You do not have sufficient permissions to perform this action}, isFromCache:false}}, isFromCache:false}
And the code is:-
String grapPath = String.format("%s/likes", postID);
Request request = new Request(Session.getActiveSession(), grapPath,
null, HttpMethod.POST, new Request.Callback() {
#Override
public void onCompleted(Response response) {
String res = response.toString();
Log.i("********************************", res
+ " Success!");
}
});
Request.executeBatchAsync(request);
Please help me for solve this problem.
the error is quite clear , you do not have the required permission to post ,
while logging the user , ask for the relevant permission "publish_actions"
For more info --> https://developers.facebook.com/docs/facebook-login/permissions
In MY android app i want to share video from android app to facebook wall.
Below is my code for doing so-
Request.Callback callback5 = new Request.Callback() {
public void onCompleted(Response response) {
Toast.makeText(mContext,"Success",Toast.LENGTH_SHORT).show();
mDialog.dismiss();
}
};
File mFile = new File(videoPath);
Request request5;
try {
request5 = Request.newUploadVideoRequest(session,
mFile, callback5);
RequestAsyncTask task5 = new RequestAsyncTask(request5);
task5.execute();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Also made changes in fb api console.But when upload video-
{Response: responseCode: 403, graphObject: null, error: {HttpStatus: 403, errorCode: 200, errorType: OAuthException, errorMessage: (#200) Requires extended permission: publish_actions}, isFromCache:false}
Edit: Permissions i have added-
` Session s = new Session(mContext);
Session.setActiveSession(s);
s.openForPublish(new Session.OpenRequest(PostVideoToFBWall.this).setCallback(callback).setPermissions("public_profile","email","publish_actions"));`
Hi i have been trying to find how to add the like button to my android code. i have done the following things can anyone help me out it always throw me this error
{Response: responseCode: 403, graphObject: null, error: {HttpStatus: 403, errorCode: 200, errorType: OAuthException, errorMessage: (#200) Requires extended permission: publish_actions}, isFromCache:false}
i have added the publish permission in my request as wel. my code below:
public void doLike(Session session, String Id) {
Bundle params = new Bundle();
params.putString("object", "http://graph.facebook.com/" + Id);
// /* make the API call */
new Request(session, "/me/og.likes", params, HttpMethod.POST,
new Request.Callback() {
public void onCompleted(Response response) {
// /* handle the result */
System.out.println(response);
}
}).executeAsync();
}
{Request: session: {Session state:OPENED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[publish_actions, publish_stream]}, appId:xxxxxx}, graphPath: /me/og.likes, graphObject: null, restMethod: null, httpMethod: POST, parameters: Bundle[{access_token=CAAT0aKyquLEBAOxF4XYENsZBFLdD7ZALvGOvQ25ZAvGl6vmCPz8AHOQcZAnKHaOOYPv4DkL0VlMu7jveZCjmht20MuB7qLWpUZAo2DPQxG16ZAF5ICouzAbwpKmMmJdEF1HN1MzCLp5GhlYyy4f63WL5wUE21wRKiYg8wJVy3AGlATcDjpU4FyZB64dZCDv66zv228ZCsuemiFIqf5Qqwcb1QIca91WfCCDZCh71ZCz9CXegCvt1CBurddDo, format=json, object=http://graph.facebook.com/xxxx, sdk=android}]}
this is my request but still getting the error
Just follow the screenshot and check did you set the above permissions?
I am using the updated Facebook SDK V3.0 final for Android. I am trying to send app requests to facebook frineds who do not have the application. The code is:
public void fbookinvite(){
Bundle postParams = new Bundle();
postParams.putString("name", "X");
postParams.putString("message", "DOWNLOAD X.");
Session session = Session.getActiveSession();
postParams.putString("access_token", session.getAccessToken());
if (session==null||session.getState().isClosed()){
System.out.println("session is null");
}else{
//meaning we are good to go.
Request request = new Request(session,"/friend facebook id/apprequests", postParams, HttpMethod.POST, new Request.Callback() {
#Override
public void onCompleted(Response response) {
System.out.println("response was: "+response.toString());
}
});
Request.executeBatchAsync(request);
}
}
When the code runs I get one of the following from the printed response:
responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2, errorType: OAuthException, errorMessage: (#2) Failed to create any app request}, isFromCache:false
... or:
Response: responseCode: unknown, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}
I have the following permissions: publist_stream and publish_actions.
After solving the problem I'd also like to know how to add a group of recipients to the app request.
I do not want to use the Facebook dialog.
Try this instead:
Bundle params = new Bundle();
params.putString("message",
"Learn how to make your Android apps social");
params.putString("to", "YOUR_FRIEND_UID_HERE");
WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(
this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
#Override
public void onComplete(Bundle values,
FacebookException error) {
// your code here
}
}).build();
requestsDialog.show();
This is the proper way to send an app request explicitly to someone. If you do not include the to parameter, the user can choose who they want to send to.
Response: responseCode: unknown, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}
This is a scenario usually related with running simultaneous FB requests on your own threads.
I learnt the hard way to use either
Request.executeAsync()
or
RequestAsyncTask