iOS FBDialogs with one FBOpenGraphAction Uploading multiple photos - ios

I'm trying to share multiple photos as open graph objects with one single action. Each photo object have a image url.
I can achieve share one photo object with one action per time, but I couldn't figure out how to share multiple photo objects at once. Any ideas?
the code I'm using is as follows:
id<FBGraphObject> photo =
[FBGraphObject openGraphObjectForPostWithType:#"photo"
title:#"photo title"
image:photoURL
url:photoURL
description:#""];
id<FBOpenGraphAction> shareAction = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[shareAction setObject:photo forKey:#"photo"];
[FBDialogs presentShareDialogWithOpenGraphAction:shareAction
actionType:#"share"
previewPropertyName:#"photo"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];

Related

Facebook iOS SDK , share an image with a caption using ShareDialog (not GraphAPI)

I'm using following code to share a picture to Facebook using ShareDialog. However I'm unable to set a caption to this. params does not have a property for a caption.
FBPhotoParams *params = [[FBPhotoParams alloc] init];
params.photos = #[image]; // this is an UIImage instance.
[FBDialogs presentShareDialogWithPhotoParams:params
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
if (error) {
NSLog(#"Error: %#",
error.description);
} else {
NSLog(#"Success!");
}
}];
However there's a different method to share a status update with a picture, but this methods allows to share an image as a web link.
presentMessageDialogWithLink:name:caption:description:picture:clientState:handler:
I want to share a local UIImage just like in my first approach, with a caption. Is this possible?
There's no support for captions via the photo share dialog. The user must type in the caption/message themselves.

Facebook "view on ..." text on custom story is not showing

I'm implementing deep linking in an app.
Followed every tutorial I found.
Tested every possible setting.
And the result is: If I post a story with "user_generated": "true", Facebook posts the big photo as it should, but there is no link like "view on Instagram", "view on Foursqare" and so on. So people can't reach the actual object.
Facebook settings:
Display Name, Namespace, App Domains, Site URL, Bundle ID, iPhone Store ID, Deep Linking (ON), Native or desktop app?(ON), Is your App Secret embedded?(OFF)
App Restrictions - No restrictions
I'v set up the open graph action and object and they are working without "user_generated": "true".
I'm sending my code (projectnamespace is replaced for this example):
-(void) shareOnFacebook: (NSString *) image {
NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
object.provisionedForPost = YES;
object[#"type"] = #"projectnamespace:photo";
object[#"title"] = _postText.text;
object[#"url"] = responseJson[#"share"];
object[#"og:url"] = responseJson[#"share"];
object[#"al:web"] = responseJson[#"share"];
object[#"web"] = responseJson[#"share"];
if (image) {
NSLog(#"Photo Link: %#", image);
object[#"image"] = #[#{#"url": image, #"user_generated" : #"true" }];
}
// Post custom object
[FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
NSString *objectId = [result objectForKey:#"id"];
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:objectId forKey:#"photo"];
[action setObject: #"true" forKey: #"fb:explicitly_shared"];
if (image)
[action setImage:#[#{#"url": image, #"user_generated" : #"true" }]];
// create action referencing user owned object
[FBRequestConnection startForPostWithGraphPath:#"me/projectnamespace:add" graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
NSString *actionId = [result objectForKey:#"id"];
NSLog(#"Posted story to facebook: %#", actionId);
[self shareAndDismiss: nil];
} else {
// An error occurred
NSLog(#"Encountered an error posting action to Open Graph: %#", error);
[self shareAndDismiss: nil];
}
}];
} else {
// An error occurred
NSLog(#"Error posting the Open Graph object to the Object API: %#", error);
[self shareAndDismiss: nil];
}
}];
}
As far as I have seen, there is no such "View on Foursquare" link on Foursquare posts being shared on Facebook.
The only "View on..." links that I am aware of are for Instagram. However Instagram is a Facebook company. The Facebook and Instagram teams work together for their own photo-sharing experience, which means they are not limited by the API as we are.
I'm afraid that "View on Instagram" is a special feature given to the Instagram app only and that the Facebook API doesn't give that ability to others apps.

Facebook share dialog auto returns to app

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!");
}
}];

How to post a photo to friend's wall (timeline) using Facebook IOS SDK dialog?

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!");
}
}];

Posting an action with user generated photo on ios share dialog

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

Resources