Here i am trying to add a post to facebook using following code.
FBAppCall *appCall = [FBDialogs presentShareDialogWithLink:urlToShare
name:#"Title"
caption:nil
description:#"description"
picture:nil
clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if (error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
But this isn't working. It give following error.
Error Domain=com.facebook.Facebook.platform Code=102 "The operation couldn’t be completed. (com.facebook.Facebook.platform error 102.)" UserInfo=0x1cde3340 {error_code=102, action_id=E780C3AA-1387-4B9C-9A3A-9A16FB54BC59, error_message=An error occurred during publishing., app_id=558567750859724}
Here i am working on cocos2d, is this can be the reason.
Go to your app's settings under the Facebook developer portal.
Go to open graph > types
Choose the action type using and turn on "User Generated Images" for that action type. Save these settings and try again. It will work.
I encountered this error as well, make sure you disable the sandbox mode in Facebook admin panel before distributing to any other user :P
I recently encountered this error when the link I tried to post did not load correctly (was loading a 404 page). Not sure why, but maybe Facebook requires the link work.. Either way they need to make their error messaging more specific.
Related
I am getting the following error when attempting to post to OpenGraph using the Share Dialog with the FB iOS SDK v 3.17.0.:
Error : Error Domain=com.facebook.Facebook.platform Code=102 "The operation couldn’t be completed. (com.facebook.Facebook.platform error 102.)" UserInfo=0x176d43a0 {error_code=102, error_description=An error occurred during publishing., app_id=xxxxxxxxxxx, error_reason=The operation couldn’t be completed. (FBAPIErrorDomain error 2500.)}
This error is returned by handler callback of the presentShareDialogWithOpenGraphAction method. When calling this method, the transition to the FB App occurs and the contents of the post are shown in the UI (although, the supplied photo shows briefly and then disappears). I also see an alert dialog in the FB App stating:
Oops, Something Went Wrong. There was a problem posting your status. We've logged the error and will look into it.
After pressing Post in the FB app, my app opens again with the above error message.
The (abbreviated) code for what I am doing is below. Note that my object type is gift, my custom method is send, and both appear to be set up correctly on the developer site. Any help is much appreciated.
id<FBGraphObject> object = [FBGraphObject openGraphObjectForPostWithType:#"myNamespace:gift"]
title:#"Gifter"
image:#"http://imgur.com/gallery/Omhe1V3"
url:#"http://www.myAppsUrl.com"
description:#"A gift for you"];
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:object forKey:#"gift"];
[action setTags:#[targetFacebookId]]; ///S.O. Note: The Id is obtained elsewhere.
FBOpenGraphActionParams *params = [[FBOpenGraphActionParams alloc] init];
params.action = action;
params.actionType = #"myNamespace:send";
// If the Facebook app is installed and we can present the share dialog
if([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params]) {
// Show the share dialog
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:#"myNamespace:send"
previewPropertyName:#"gift"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
NSLog(#"Error : %#",error);
}];
}
Look carefully on the parameters you provide. FB doesn't tell you what's wrong but just returns this general error.
I just had the same problem and apparently my namespace was wrong.
So my suggestion - double and triple check all the params you are passing to FB
I followed the set up for my own application. https://developers.facebook.com/docs/ios/getting-started/
I then used the overview example, found here: https://developers.facebook.com/docs/ios/share-dialog/
NSURL* url = [NSURL URLWithString:#"https://developers.facebook.com/"];
[FBDialogs presentShareDialogWithLink:url
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
The share dialog appears, like in the example. I press post and it successfully returns to the app. All looks like its working right? But when I return to the facebook wall and my profile there is no status update. The logs are not displayed so something is going wrong.
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
Any ideas? Facebook redirect you to stackoverflow to get help because they have facebook developers registered.
First, the final part on the first link, about the .plist, is really important. It has to be with the correct info from your app, in order to the share feature to work. Re-check that if you can.
Anyway, the NSLog not printing anything on the console is strange, have you tried searching(command + f) for the message output on the console? Did you try debugging your app and putting breaking points on the 'if' condition to see the state of the error instance?
I don't know if you didn't put it here, or forgot to do it on code, but are you logging the user and checking if the facebook user session is valid? That has to be checked in order for the share to work.
PS: If you are using your facebook App on sandbox mode, any share you do, will only appear on the timeline of the users that are allowed to use the fbApp.
I am creating an iOS app where I want to allow the user to like a specific URL. I've tried to use the following code (as mentioned on the Facebook developers page) to like a specific url:
**- (IBAction)likeClicked:(UIButton *)sender {
SLAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
[FBSession setActiveSession:appDelegate.session];
if (appDelegate.session.isOpen)
{
NSMutableDictionary<FBGraphObject> *action = [FBGraphObject graphObject];
action[#"object"] = #"http://samples.ogp.me/226075010839791";
[FBRequestConnection startForPostWithGraphPath:#"me/og.likes"
graphObject:action
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSLog(#"Error %#",error.localizedDescription);
NSLog(#"result %#",result);
// handle the result
}];
}
}**
But the above code only allows me to like the URL if I am authorized as an admin of that app on the facebook developer page.
If I am not an admin to the app with that specific app id , I get an error description as following:
Error The operation couldn’t be completed. (com.facebook.sdk error` 5.)
There are different solutions given on Stack Overflow for this but none of them seem to be working for me. I've checked for permissions and I have added the "publish_actions" permission to permissions list.
Is there another reason why i might be getting this error?
Is there another workaround using which i can like a specific URL on facebook?
There would be couple of places to check
- Is your Facebook app under "sandbox mode", if it is you will have to turn it off once you are sure with your development.
If you have just created a FB graph action:
You are required to submit the action through the FB developer console and it usually takes couple days for them to approve, and once approved other users can start using the "like" action.
Until you get the action approved, only the App developers, testers and admins (on the FB developer site) for this particular app would be able to complete the action and see the results on their FB timeline.
When I run same code in simulator I get success Response for image post:
{
id = 248572435289479;
"post_id" = "244759709004085_248572441956145";
}
When I run in same code in device I get:
Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x208a8dd0 {error={
code = 1;
message = "(#1) An unknown error occurred";
type = OAuthException;
}}
"
OAuthException means that there was an authentication issue. Be sure that the following are true on your device.
You are logged into a facebook account successfully
If you are, then remove the app from the phone
Do a clean and re-deploy to the phone
If none of the above work, try logging out in Settings on the phone and logging back in. Then try logging in through safari. Sometimes the iOS facebook authentication can be a little buggy. Also try a different app that is guaranteed to work with iOS facebook accounts. Something like, Hootsuite.
If there is still an issue after all that... I am not sure what you tell you.
This link might help you.
and #giff's answer also explains it to some extent on this link.
log of your issue in this might help you to get further detail of your error.
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
NSLog(#"%#", [error localizedDescription]);
NSLog(#"Err details: %#", [error description]);
};
I recommend you to try this if none of the solutions given above could help you.
Remove the application from the list of authorized applications and authorize it again with the needed permissions.
Hope this works for you
I'm uploading photos to Facebook from my iPhone application. I've got it working, except that sometimes, it returns "Unknown Error Occurred". I'm not sure what the problem is. This happens about 75% of the time.
Has anyone else encountered this?
Still not sure what was happening, but I solved the problem. Here's what I did:
- (void)request:(FBRequest*)request didFailWithError:(NSError*)error {
if ([error code] == 1 && [[request method] isEqualToString:#"photos.upload"]) {
FBRequest *tryAgain = [FBRequest requestWithDelegate:self];
[tryAgain call:[request method] params:[request params] dataParam:(NSData *)[request dataParam]];
}
}
Essentially, I just made it try again. Resending the same request didn't work (failed with an invalid signature), so I created a new request with the properties of the old one.
The nice thing about this is that it is sort of recursive: if the new request fails too, it will just keep trying. I hope I don't encounter any negative side-effects of that, though.
Try it on the simulator and use an http debugger like Charles to see what is happening during the transfer and what the response is from Facebook.