I'm trying to create a share button which share a post on Facebook. I've found this code below under Dialogs and UI controls on the Facebook developer page. It works just fine. The only problem is that after a few seconds on the Facebook post page it automatically goes back to the app without me clicking on anything. The below code is everything related to Facebook I've added, beside the plist Facebook app info.
How come it automatically returns to the app?
Code :
id<FBGraphObject> mealObject =
[FBGraphObject openGraphObjectForPostWithType:#"cooking-app:meal"
title:#"Lamb Vindaloo"
image:#"https://example.com/cooking-app/images/Lamb-Vindaloo.png"
url:#"https://example.com/cooking-app/meal/Lamb-Vindaloo.html"
description:#"Spicy curry of lamb and potatoes"];
id<FBOpenGraphAction> cookAction = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[cookAction setObject:mealObject forKey:#"meal"];
[FBDialogs presentShareDialogWithOpenGraphAction:cookAction
actionType:#"cooking-app:cook"
previewPropertyName:#"meal"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
Related
I have integrated Facebook Sharing of a link with a description, caption, etc via the Native Facebook App (if it is installed) using the code:
FBLinkShareParams *params = [[FBLinkShareParams alloc] initWithLink:[NSURL URLWithString:#"https://abcde.com"]
name:#"demo"
caption:#"demo"
description:#"demo"
picture:nil];
//Present share dialog
[FBDialogs presentShareDialogWithParams:params clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
// Success
NSLog(#"result %#", results);
}
}];
When this method runs, and the native facebook app is installed, I get an option to share a post that has caption, link and description. When I click share and I go on FB to check it, it appears to only have the link?
Can someone suggest a possible fix?
Most likely it is due to newest Facebook sharing policy 2.3
I am attempting to share a generated image through the facebook app with the FBDialog class. The idea is to allow tagging of friends and locations so the SLComposeViewController isn't quite as ideal (though I am falling back to that). The problem is that after it opens the facebook app and the users presses share, it never actually shares. It gets stuck at the loading screen and the bar keeps starting back from 0%, going past 100%, then back to 0.
I'm using the following code. I'm not sure if this is a problem with my implementation or with the facebook app itself.
if ([FBDialogs canPresentShareDialogWithPhotos]) {
FBPhotoParams *params = [[FBPhotoParams alloc] init];
UIImage *img = [self generatePrayerImage];
params.photos = #[img];
[FBDialogs presentShareDialogWithPhotoParams:params
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
if (error) {
NSLog(#"Error: %#",
error.description);
} else {
NSLog(#"Success!");
}
}];
}
Thanks.
I was able to fix this by setting the correct facebook app name in my info.plist. For some reason there must have been a small difference between the one I set on developer.facebook.com and my app.
How to post a photo to friend's wall like when you post a photo using facebook site (using "Post" form at the top of friend's wall and switched to "Photo" tab). Result should be something like this:
I know how to post a simple post to friend's wall using [FBWebDialogs presentFeedDialogModallyWithSession..] and #"to" parameter. But is there any way to post exactly a photo (with big thumbnail)?
Removing the ability to post to friends' timelines via API
We have found that posting content via API (stream.publish) on a friend's wall lead to a high incidence of user dissatisfaction (hiding content, blocking the app). After the migration period, posting content to friends' timelines via stream.publish will no longer be allowed. Please use the Feed Dialog for posting
// only supports passing a single image
NSArray* images = #[
#{#"url": [UIImage imageNamed:#"my-awesome-meal-photo.jpg"], #"user_generated" : #"true" }
];
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:#"https://example.com/cooking-app/meal/Lamb-Vindaloo.html" forKey:#"meal"];
[action setObject:images forKey:#"image"];
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:#"fbsdktoolkit:cook"
previewPropertyName:#"meal"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
I am trying to submit what I think is a pretty basic open graph post on facebook in iOS7. I am using the latest version of everything, including facebook's SDK version 3.10.
My app brings up the share dialog preloaded with the parameters from my FBGraphObject. I even had an image URL in there earlier that shows in the preview, just took it out trying to troubleshoot. I type a few words in the "Say something about this..." part of the share dialog and tap "Post." This is the error I get:
Error Domain=com.facebook.Facebook.platform Code=102 "The operation couldn’t be completed. (com.facebook.Facebook.platform error 102.)" UserInfo=0x19192ba0 {error_message=An error occurred during publishing., app_id=299416296871047, error_code=102}
I can't seem to find another question with this same error. Here is my code:
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
NSMutableDictionary<FBGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:#"og.item"
title:#"Test Post"
image:nil
url:#"https://mywebsiteurl.com"
description:#"A test post"];
[action setObject:object forKey:#"something"];
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:#"og.publish"
previewPropertyName:#"something"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
NSLog(#"Results: %#", results);
} else {
NSLog(#"Success.");
}//end if
}];
Any ideas?
I had the same problem. It turned out to be permission issue. Facebook user that that I used to post OG story wasn't administrator or the developer in the Facebook app roles and permissions.
In order to use it with any user your app has to be reviewed by Facebook.
I had the exact same problem. What's the size of the OG object in the URL?
Mine was rather large and the Facebook app was not waiting long enough to complete the post.
At the moment i'm publishing successfully via FBRequestConnection startForPostWithGraphPath
// create object
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:url forKey:#"something"];
[action setObject:#"true" forKey: #"fb:explicitly_shared"];
[FBRequestConnection startForPostWithGraphPath:#"me/og.item"
graphObject:action
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];
Make sure the 'Explicitly Shared' option for this action type is enables in the App Dashboard.
What i was trying to do was to publish a camera generated photo into facebook with an open graph action.
here is the code i used:
UIImage *imageToShare = [EXPOINNOVAImageCombiner mergeImages:photo TopImage:tbot];
//Custom UIImage to be shared on facebook
NSArray* images = #[#{#"url": imageToShare, #"user_generated" : #"true" }];
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:#"http://emaginelab.com/FBAction/fbtbot.html" forKey:#"tbot"];
[action setObject:images forKey:#"image"];
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:#"expoinnovaapp:took_a_photo_with"
previewPropertyName:#"tbot"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
When i set the user_generated flag to false, the post works, but if its true facebook tries to post it, but falls back to the app before the upload finishes.
I already registered my app in facebook, and added the user generated photos capability so, in theory, the app should post a larger version of the photo in the user timeline.
btw the image is 640x640
what am i doing wrong here?
thanks in advance