I am trying to post dictionary to facebook in which image is attached, when user click on the image then should redirect the user to a link. I need to share the dictionary in the format shown in the attached image. If anybody knows that how can I achieve
the attached format then please let me know.
Please try this code , i also use this code for my app and resolve a issue ..
- (void)sendDataOnfacebook {
[self performPublishAction:^{
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"FASHMOD", #"name",
strFBPostUrl,#"link",
strFBPostTitle, #"message",
strFBPostImageUrl,#"picture",
#"Be a fashion model",#"description",nil];
[FBRequestConnection startWithGraphPath:#"me/feed"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,id result,NSError *error)
{
NSLog(#"Shared successfully");
NSLog(#"status %# %# ",result,error);
}];
}];
}
Related
I'm using this code to upload a photo on the Facebook user wall but the result dictionary return to me only photoid and postid, i need to know the permission level of the post that i have just share (during sharing process in native app the user can select Public,friends,only me...), There a way to know this permission?
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"", #"message", nil];
[params setObject:Picture forKey:#"source"];
[FBRequestConnection startWithGraphPath:#"me/photos"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error)
{
//showing an alert for failure
}
else
{
//showing an alert for success
NSString *phoId=[NSString stringWithFormat:#"%#",[result valueForKey:#"id"]];
NSString *PostId=[NSString stringWithFormat:#"%#",[result valueForKey:#"post_id"]];
}
}];
You can do another Graph API Call using the post id of the photo you have just uploaded. The specific field you want to ask for is called 'privacy'. This field is an object. One of its properties is 'value', which can be one of the following:
Everyone
All Friends
Friends of Friends
Self
Custom
From this, you can check the privacy people have specified on your post and adjust accordingly.
More info here: https://developers.facebook.com/docs/graph-api/reference/v2.3/post
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.
I am trying to post on users wall using ios app by using FB New graph API 3.17.1.But when I post using the graph path me/photos, it will create an bunch of post at one location instead of posting the images as separate story.
I did lot of R&D and found this Post photo on user's wall using Facebook iOS SDK
I used below method to post on user's wall
NSMutableDictionary* postParams = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
#"<Image URL>", #"picture",
#"Facebook SDK for iOS", #"name",
#"build apps.", #"caption",
#"testing for my app.", #"description",
nil];
[FBRequestConnection startWithGraphPath:#"me/feed"
parameters:postParams
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result,NSError *error)
{
if (error)
{
NSLog(#"Error in uploading the photo %#",error);
}
}];
This method does paste the image on user's wall but for this image has to be uploaded somewhere on internet and we have supply the URL of same.And additionally it makes image visibility very less compared to image posted using me/potos.
[FBRequestConnection startWithGraphPath:#"me/photos" parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection*connection, id result, NSError *error)
{
NSLog(#"Error : %#",error);
NSLog(#"%#",result);
}];
I used above method but it will group the photos into bunch and make the album on the users wall after 3-4 post. And additionally it has limitation of max 25 post per app per day. So this method is negligible.
Please let me know any alternative way, if anyone has used.I would be very thankful.
I have used FacebookSDK.framework for Facebook integration in my application. I have to like one facebook page from application. I have used following code for liking page.
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:#"https://www.facebook.com/demoappname"
, #"object",
nil
];
/* make the API call */
[FBRequestConnection startWithGraphPath:#"me/og.likes"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
)
{
NSDictionary *currentResult= [(NSArray *)[result data] objectAtIndex:0];
if(!error)
{
NSLog(#"there is no error");
}
else
{
NSLog(#"There is something wrong at here.");
}
}];
But I am not clear what I have to pass in "object" parameter. Can anybody help to what I am doing wrong at here.
Thanks,
If you read this documentation, it says-
The og.likes action can refer to any open graph object or URL, except for Facebook Pages or Photos.
So, liking a page with Graph API isn't possible.
The only thing you can do- add a Like Button to the page in your app.
I am using facebook sdk and need to share details to facebook timeline. I am using the following api call.
[FBRequestConnection startWithGraphPath:#"/feed"
parameters:dictionary
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (!error) {
[VBUtility showAlertWithTitle:#"Facebook" message:#"Deal details posted successfully"];
}
}];
The story is published on facebook, not at user's timeline but user's newsfeed (The document tells this method does - posts and links published by this person or others on their profile.). I have also tried with /home method call. While I tried with the built in facebook share,
SLComposeViewController *fbPost = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
it is perfectly published to user's timeline as well as in news feed. I have configured the app in the developer.facebook.com. Do I need to mention any permissions here. Does any one can help me finding the mistake?
Permission Request,
NSArray *permissions = [[NSArray alloc]initWithObjects:#"publish_actions",#"user_birthday",#"publish_stream",#"user_about_me",#"email",#"basic_info",nil];
The parameters passed are,
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
app_id, #"app_id",
name,#"name",
caption, #"caption",
description,#"description",
link, #"link",
picture, #"picture",
#"1",#"fb:explicitly_shared",
nil];
Try this,
[FBRequestConnection startWithGraphPath:#"me/feed"
parameters:dictionary
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (!error) {
[VBUtility showAlertWithTitle:#"Facebook" message:#"Deal details posted successfully"];
}
}];
I changed little bit from your code. Change your path as #"me/feed". I hope, this may help you.