Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook iOS SDK: Post on my wall with mention friends

I would like to make post with an image, message and mention some friends. I'm posting photo using Graph API

[FBRequestConnection startWithGraphPath:@"me/photos" parameters:dictionary HTTPMethod:@"POST" completionHandler:

and got friends list using

[FBRequestConnection startWithGraphPath:@"/me/taggable_friends"
                                              parameters:nil
                                              HTTPMethod:@"GET"
                                       completionHandler:

every friend has an id like this "AaJIwZcI7HgWAY1FXkqc5AMjIzE3k8TEuv9YligJRa_2M1EmZ3iGvFZxRpF6s1eW3pCNKep2RUxy5KWH3WgOSUH3QSRLH_RRaTlfgcFjRX9DpQ" but how implement this id in message?
I have used different ways but nothing:
https://developers.facebook.com/docs/opengraph/using-actions/v2.1#people

[dictionary setObject:array forKey:@"tags"];
[dictionary setObject:[NSString stringWithFormat:@"@[%@:1:%@]",userID,userName]forKey:@"message"];

Any idea or something that help?

like image 833
Iraklii Avatar asked Oct 11 '14 12:10

Iraklii


People also ask

What information can I share with Facebook through the SDK?

By enabling Facebook integrations, including through this SDK, you can share information with Facebook, including information about people’s use of your app. Facebook will use information received in accordance with our Data Use Policy, including to provide you with insights about the effectiveness of your ads and the use of your app.

How do I enable friends to post on my facebook wall?

Click on Customize Settings. Step 3: Check the box Scroll down to the category "Things others share" on the Customize Settings page. Under that category is a "Friends can post on my Wall" option with a check box. Click the box to enable Friends to post to your Wall.

How do I make sure people can't see my facebook wall?

Make sure they can get to your Wall by checking your settings. Step 1: Log into Facebook Log into Facebook. Click the Account button, and then Privacy Settings. TIP: Review all your Privacy Settings to make sure you are only showing people what you want.

What is the latest version of the Facebook SDK for iOS?

You can also download the latest version of the Facebook iOS SDK, integrate it into your app, and recompile. Beginning with SDK v13.0, set to release in early 2022, a Client Token will be required for all calls to the Graph API. The Facebook SDK for iOS contains component SDKs that you can connect to individually.


1 Answers

Mentioning friends may looks pretty easy, but in fact it is really complicated thing worth big tutorial and involving a lot of steps to be done and api requests to be performed. To do this you should create object and do some action with it. As for terminology:object consists of generic data such as type, image, title, url, custom fields, etc. action consists of object and can also mention friends. Thus:

  1. You should create custom story on your app's page in section "open graph" or use existing one from here. Since now assume we create custom story.
  2. You should perform request to create object. You can get sample requests from your app's page in section "open graph" by clicking "get code" button on the right of story. Those request for http (not for ios in particular) but show all necessary fileds that must be filled in to perform requests successfully.
  3. Than upload some image(s) and keep their urls (how to upload photo into Facebook note:it doesn't get you url and you need to retrieve it using simple get request. i know it is stupid but unfortunately the only way to get url from photo posted just a second ago).
  4. Get taggable friends and keep their pseudo-ids.

  5. Perform request for action. It is the place where all magic is done. Perform request with necessary fields: "image", "tags" and, probably "fb:explicitly_shared" (obviously set to true). Note that "image" is array, "tags" are comma-separated values, "fb:explicitly_shared" is boolean value. From the ios perspective request could look like this:

   [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"me/%@", kFBActionNameFull]
                                      parameters:@{kFBObjectNameShort:objectId,
                                                   @"fb:explicitly_shared":@"true",
                                                   @"tags":@"friend1_tag,friend2_tag",
                                                   @"image":@[@{@"image":@"some_url",
                                                                @"user_generated":@"true"}]}
                                      HTTPMethod:@"POST"
                               completionHandler: ...]

After all this steps you could see story on your page.

As you can see mentioning friends is very difficult task, requiring a lot of time to implement. I could add some code to explanation above, but without deep understanding of stories mechanism you can not successfully post image and tag friends

And yes, you must

  1. Send your app with story and all requested permissions to submission

in order to use your app into production.

like image 75
Fyodor Volchyok Avatar answered Sep 23 '22 09:09

Fyodor Volchyok