i m trying to post images on friends fb wall, im getting selected friend ID,
and image that is converted in base64 string
just getting response as error below
{Response: responseCode: 200, graphObject: null, error: {HttpStatus: 200, errorCode: 3, errorType: null, errorMessage: Unknown method}, isFromCache:false}
my code below
if (hasPublishPermission()) {
Request postToWall = new Request();
for (GraphUser friend : selectedFriends) {
Constants.showLog("Selected Frnd", friend.getId());
Constants.showLog("Selected Pic", picture);
Bundle parameters = new Bundle();
parameters.putByteArray("message", "Greetings from Wish Well!".getBytes());
parameters.putByteArray("link", "http://pictwist.cloudganga.com".getBytes());
parameters.putByteArray("picture", picture.getBytes());
parameters.putByteArray("target_id", friend.getId().getBytes());
postToWall = Request.newRestRequest(Session.getActiveSession(), friend.getId() + "/feed", parameters, HttpMethod.POST);
Constants.showToast(getApplicationContext(), "Posted image on friend wall");
}
postToWall.setCallback( new Request.Callback()
{
#Override
public void onCompleted(Response response)
{
Constants.showLog("Responce Posting image", response.toString());
}
});
Request.executeBatchAsync(postToWall);
}
please help
Posting image or any content on friend's walls is no more supported by the sdk since feb 6, 2013. You need to use the feed dialog to do that..
check this link..
https://developers.facebook.com/roadmap/completed-changes/
Related
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"));`
I ma trying to read facebook event's details from an ANdroid application by using this code :
new Request(
session,
"me/events/created",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
System.out.println("Result: " + response.toString());
}
}
).executeAsync();
but I m always receiving a ampty response :
Result: {Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"data":[]}}, error: null, isFromCache:false}
Although when i tried the Graph API Explorer https://developers.facebook.com/tools/explorer i get the right list !!!!
Have you configured the correct permissions for your app? To get the User's Events, you need to aquire the user_events permission upon login.
See https://developers.facebook.com/docs/graph-api/reference/v2.0/user/events/#readperms
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