Photo posted via FB Graph API doesn't appear on the wall (and 2 more FB questions) - iphone

I post photo on the wall using Facebook Graph API, just set parameter "picture" and send POST request to "me/photos".
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
self.imageToFBPost, #"picture",
FACEBOOK_ICON_URL, #"icon",
nil];
[facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
Usually (basically always) when I add photos to my PF they appear on my wall. But not in this case. I've tested yesterday about 20 times and only 1-2 times photos appeared on my wall. Basically I want them to appears on my friend's feed. Main question: is there any way to make photo appear on my wall each time she it was posted?
Second question is how to customize icon of the post? E.g. when I of mobile upload under the wall post I see this icon: . I want to see icon of my app instead. I 've set icon of my Facebook app, but it isn't showed anywhere...
3rd question is how to get link to the Facebook page with a photo?
As result of request mentioned above I receive "id" of the picture. I want to open Safari with Facebook page of uploaded picture. Is it possible? I can find only direct link to the .jpg file, but not to the FB page. I've tried to go to http://graph.facebook.com/photo_id but it does't work...
Also it isn't very clear for me ho to catch various responses in the same file. E.g. if I do login, photo posting and requesting photo info in the same class. I created request_id class variable for that and execute switch/case in method comparing request_id with constants, but this way looks "ugly" for me. Any nice solution? :)
Thanks!

1rst question: Facebook decides what to display on your friends feed. displaying one post per photo would be overwhelming so FB chooses to group your images by album into the same post.
2nd question: in your application settings page (https://developers.facebook.com/apps) you can modify the icon displayed for each one of the posts.
3rd question: each requestWithGraphPath methods return a FBRequest instance ref. Keep it somewhere and once your delegate gets called back, compare the passed FBRequest with the ones you kept asside.

Related

Facebook Graph post image to page

I can succesfuly upload pictures to my own wall by posting an image to https://graph.facebook.com/me/photos. Now i need to post to a page's wall instead. I have the page ID, but when i change "me" in the url to the pages ID, the image is still posted to my own wall instead of the page's. How do i post an image to a page's stream?
And which permissions is required to do so?
It would be great if you guys could help me out, has got stuck on this one. Thank you!
You cannot upload pictures to wall (it's uploading to album).
To upload picture to Page's Album you need to use page access_token that is accessible via accounts connection of user (you'll need manage_pages permission to get this info).
Once you have access_token for page you may upload picture in the same way as you do for user but using page id instead of user id (you will need publish_stream permission for user to post content pages he own).
m_imgData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForAuxiliaryExecutable:#"Default.png"]];
NSMutableDictionary *fbArguments = [[[NSMutableDictionary alloc] init] autorelease];
[fbArguments setObject:self.m_imgData forKey:#"source"];
[fbArguments setObject:#"Uploading images" forKey:#"message"];
[m_facebook requestWithGraphPath:#"Page_ID/photos"
andParams:fbArguments
andHttpMethod:#"POST"
andDelegate:self];
Where i am using Default.png as a image to upload.
m_facebook is allocated object of Class Facebook (Provided as a part of Facebook SDK).
m_imageData is an object of NSData.

FBConnect iOS: Post photo to feed with message every time

I am working on an iOS app that needs to post to either Twitter, or Facebook, or both, every N minutes. The post needs to include a photo and message. I have this woking fine for Twitter, however I'm running into some issues with FBConnect.
The only way I've found to post an image using the image data, rather than a link, is to post to /photos (graph API) and include a message parameter. Unfortunately, it seems that after the first post, subsequent posts either don't show up, or show up as "User added photo to album {app_name}", instead of the message and photo.
Here is my code:
NSMutableDictionary* params = [NSMutableDictionary dictionary];
[params setObject:message forKey:#"message"];
if (image) {
[params setObject:image forKey:#"picture"];
[fb requestWithGraphPath:#"me/photos" andParams:params
andHttpMethod:#"POST"
andDelegate:self];
} else {
[fb requestWithGraphPath:#"me/feed" andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
Is there a way to post an image to the feed directly so that the message and photo show up every time? The only way I could think of was to post a photo to the album and then make a second call to add a feed post with a link to the photo in it, but I'd really rather make just one call.
There's no way to do it directly. Your approach is good.
Even using a second call to add a feed post with a link to the photo from your FB album won't work. You will get a "FBCDN image is not allowed in stream" error.
It seems that you have to upload your picture to a server other than Facebook, and then post a link to that picture to the feed request.
I know it sounds pretty crappy, but I have not found anyway around it yet. I don't understand why Facebook doesn't want to allow wall posts that use a photo in an album as the thumbnail.

How to display Facebook Fan Wall in iPhone App?

I would like to display Facebook Fan Wall like the way in the image below. Can you please let me know how it can be done?
Thanks!
You can pull in the list of wall feeds from https://graph.facebook.com/cocacola/statuses?access_token=... (a preview can be seen with the graph api explorer here). Then you would just parse the returned JSON and put them into UITableView cells.
You need to post to your friends feed, Easy way would be to adapt your code to use the appropriate graph method with the persons you wish to post to facebook ID (i've assumed here you have stored this from an earlier call the graph api in person.facebookID)
[facebook requestWithGraphPath:[NSString stringWithFormat:#"%#/feed/",person.facebookID] andParams:params andHttpMethod:#"POST" andDelegate:self
http://developers.facebook.com/docs/reference/api/post
To get a list of the users friends use the graph path me/friends
[facebook requestWithGraphPath:#"me/friends" andDelegate:self];
Which will return a JSON list of the users friends names and their Facebook ids, to the appropriate delegate method from FBRequest, its probably worth wrapping this set of results into a set of person objects or storing the returned NSDictionary so that you can retrieve individual friends, its upto you how you process the list of returned friends (you probably want to use a UITableView to display the user friends or filter based on some other input from the user)
Using this method will mean you do not have to use the Facebook dialogs in the iOS sdk, which does mean there is an upper limit to how many messages the user can post in a day using your app
If you wish to use a dialog you will need to include the target_id in your params dictionary and set this to the persons Facebook ID you wish to post to

iOS Development: How can I get a Facebook wall post to show in the friend's news feed?

I'm integrating Facebook into my iPhone app and I have the code working to publish a post to the user's wall after they login, but I've noticed that the post doesn't show up in the user's news feed that's seen by the user's friends. Instead, it only shows up on the wall of the user. Here's my code...
- (void)publishStream
{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Post a message on your wall", #"user_message_prompt",
#"Hello, World!", #"message",
nil];
[facebook dialog:#"feed"
andParams:params
andDelegate:self];
}
How can I have it show up in the news feed as well? I should mention that the only permission I have set is 'publish_stream' which, as I understand it, is the only permission I need.
Thanks so much for your wisdom!
You need to post to your friends feed, Easy way would be to adapt your code to use the appropriate graph method with the persons you wish to post to facebook ID (i've assumed here you have stored this from an earlier call the graph api in person.facebookID)
[facebook requestWithGraphPath:[NSString stringWithFormat:#"%#/feed/",person.facebookID] andParams:params andHttpMethod:#"POST" andDelegate:self
http://developers.facebook.com/docs/reference/api/post
To get a list of the users friends use the graph path me/friends
[facebook requestWithGraphPath:#"me/friends" andDelegate:self];
Which will return a JSON list of the users friends names and their Facebook ids, to the appropriate delegate method from FBRequest, its probably worth wrapping this set of results into a set of person objects or storing the returned NSDictionary so that you can retrieve individual friends, its upto you how you process the list of returned friends (you probably want to use a UITableView to display the user friends or filter based on some other input from the user)
Using this method will mean you do not have to use the Facebook dialogs in the iOS sdk, which does mean there is an upper limit to how many messages the user can post in a day using your app
If you wish to use a dialog you will need to include the "target_id" in your params dictionary and set this to the persons Facebook ID you wish to post to

Facebook for iPhone, background wall post

I am implementing the Facebook iOS SDK into my app... and find no problems with that. BUT, what I can't find to figure out is how to send basic wall post to my facebook app wall.
What I want to do is whenever a user searches for something, the app sends a wall-post with the following text "#someUser just searched for someSearchQuery" to my apps wall (not the users wall).
Offcource this is something I want the user to be able to switch on / off in the settings page, so the user is aware of it.
How can I do this?
Best regards,
Paul Peelen
Use the new Graph API as described here:
http://developers.facebook.com/docs/api#publishing
Quoting:
"For example, you can post a new wall post on Arjun's wall by issuing a POST request to https://graph.facebook.com/arjun/feed"
To use the Graph API from Facebook iOS SDK do something like:
[facebook requestWithGraphPath:#"[your app's id]/feed" andParams:params andMethod:#"POST" andDelegate:self];
where params is a dictionary with following optional keys:
message, picture, link, name, caption, description, source