How to pass parameters to Facebook, fb://publish/? - ios

From my iOS app, I want to open the Facebook application to make a post in the user wall. I want to give a predefined text to make the post, and I don't know how to add the text to the call.
NSString *post = [NSString stringWithFormat:#"fb://publish"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:post]];
How could I pass the text parameters with the "fb://publish/" option?

From Safari, some HTML like this seems to be working:
...
It opens up the Facebook application's share dialog with the text predefined, which you have to edit before you can actually share it. You can also include URLs into the text; Facebook converts that to a simple link once posted, but it does not add the image or any other meta details defined on that URL, as usual.
Note this redirects to the old style publish screen,
not the one the Facebook application has been using since version 3.4.

First install the Facebook API and try this code...
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
FBAppID, #"130506840369385",
#"http://developers.facebook.com/docs/reference/dialogs/", #"link",
#"http://fbrell.com/f8.jpg", #"picture",
#"Facebook Dialogs", #"name",
#"sdsdds", #"caption",
#"asdasdasd", #"description",
#"hi goolwihdfkasnv", #"message",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];

For posting status to facebook use this URL:fb://publish/profile/me?text=foo

Related

Facebook post from IOS not working

I am trying to post something from my IOS app to facebook feed. Below is the test I included in my code.
Facebook *facebook = [[Facebook alloc] initWithAppId:FB_APPID_REMOTE andDelegate:self];
// Create the parameters dictionary that will keep the data that will be posted.
NSMutableDictionary *fbParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My test app", #"name",
#"http://www.google.com", #"link",
#"FBTestApp app for iPhone!", #"caption",
#"This is a description of my app", #"description",
#"Hello!\n\nThis is a test message\nfrom my test iPhone app!", #"message",
nil];
[facebook requestWithGraphPath:#"me/feed" andParams:fbParams andHttpMethod:#"POST" andDelegate:self];
However, I do not see the post updated to my facebook feed. Am i missing out anything here?
The method requestWithGraphPath returns an object of FBRequest. So you can check request.state to determine the status of the request, and check request.error to know what's exactly the problem.
Using AppDelegate will result in returning to the same page View you called from the ViewController. But as you are not getting any obvious error log or crashes, I think it is some issue with the Facebook graph protocol.
Replace "me/feed" with just "feed" as that works fine for me.

Non standard URLs in Post

I'm working on an iPhone app that shares data via a custom url scheme. This is working well in email, but I'm having difficulty getting this functionality in Facebook.
I would like to post a link with a callback to my app using my custom url scheme. Basically, I'd like a link that opens the app, if you're running on an iOS device with the app installed.
I'm attempting to do this using properties in a feed dialog, but on calling the dialog I get the error: The post's action links must be valid URLs... It appears that the API does not allow non-standard urls in the properties based on this - is there another way to do this?
SBJSON *jsonWriter = [SBJSON new];
NSDictionary *propertyvalue = [NSDictionary dictionaryWithObjectsAndKeys:#"Final Count", #"text", #"finalcount://somecustomstuffhere", #"href", nil];
NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:propertyvalue, #"Import ", nil];
NSString *finalproperties = [jsonWriter stringWithObject:properties];
NSString *finalactions = [jsonWriter stringWithObject:actions];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"app_id",
#"http://itunes.apple.com/us/app/final-count/id532992913?ls=1&mt=8", #"link",
#"http://southwestgecko.com/wp-content/uploads/2012/05/PrimaryIcon#2x.png", #"picture",
#"Final Count", #"name",
#"caption", #"caption",
#"description", #"description",
finalproperties, #"properties",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
This is how I ended up doing it:
I took advantage of the fact that my WordPress based web site will ignore anything after the normal URL, and packed in all the callback data there. The Facebook app is smart enough to forward the full URL string onto the app, and my app is smart enough to ignore the first part of the URL that belongs to the WordPress web site.
This is the link I put into the Facebook post:
link = [NSString stringWithFormat:#"http://southwestgecko.com/?page_id=%i%#",timer.link, [self generateURLFromTimer:timer]];
where the [self generateURLFromTimer:timer] part generates the callback information. This gets put into the dictionary params from the original question under the key #"link". When a URL gets passed into the app, I simply parse out the part pointing to the web site and process the rest as a callback (which in this case includes all the timer information needed to import the timer into my app).

Can I avoid Captcha dialog when posting picture using Feed Dialog in iOS SDK?

I am using the dialogs in Facebook iOS SDK to allow users's of our app to share a link on their news feed (SDK downloaded today to ensure I have latest version). This was working last week and began behaving differently last Friday after an outage of the API service and a capture dialog is now appearing before the user can post. But the captcha image doesn't load and it says Unknown Error in the top right corner of the captcha dialog which is ugly and seems incorrect.
Has the Facebook API changed recently to now require captcha when posting picture or link? If I remove either picture or link from the params then the post dialog loads fine. I've tried a variety of different urls for my picture or link value and nothing seems to work except removing that param completely which I don't want to do. Can I post a picture or link without the captcha step?
This is my code.
- (void)publishStream:(NSString *)postName caption:(NSString *)caption
{
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary
dictionaryWithObjectsAndKeys:
#"Company Website",
#"name",
#"http://mycompanysiteurl.com",
#"link",
nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"app_id",
#"http://mypictureurl.png", #"picture",
postName, #"name",
caption, #"caption",
actionLinksStr, #"actions",
nil];
[_facebook dialog:#"feed" andParams:params andDelegate:self];
}
I've tried various combinations of permissions when authorizing too with no luck (publish_stream, read_stream, publish_actions, photo_upload).
Not sure if I'm missing something obvious by I've been trying to fix this for days and have not found a solution other than removing the picture or link which is not an option for me due to requirements.
Thanks in advance.

iphone posting link to facebook wall - image

I am posting a link to my fb account via fbgraph API. The thing is that when I post the link to fb, an icon is appearing on left side of that link i.e, for example if I post www.google.com ,then the google image is appearing in left side of the link.
how to change that default icon to my desired icon ? (or) what is the default image location it is taking from the site.
Any idea ?
Thanks
You can set in facebook for your app.
https://developers.facebook.com/apps
It is your app icon.
For example mine is a giant wale ;-)
To add a picture to your post just add the parameter #"picture" and fillin the url to the picture you want to see.
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"myFacebookAppId", #"app_id",
#"http://www.homepage.com", #"link",
#"http//www.homepage.com/sillypicture.png", #"picture",
#"name of the post", #"name",
#"caption of my post", #"caption",
#"content of my post", #"description",
#"my message", #"message",
nil];
[[[myAppDelegate sharedDelegate] facebook] dialog:#"feed" andParams:params andDelegate:self];

How to post a string and an image using facebook api for ios

i have a ui image and a nsstring .How do i post it to the the wall of a user using fb api for ios.
You need to upload an image somewhere, in order to obtain an image url. once you have the url, you can post it something like:
[_facebook requestWithGraphPath:#"feed"
andParams:[NSMutableDictionary dictionaryWithObjectsAndKeys: FEED_MESSAGE, #"message",
IMAGE_URL, #"picture",
LINK, #"link",
name, #"name",
description, #"description", nil]
andHttpMethod:#"POST"
andDelegate:self];
Note that the "picture" key is the actual url of the image, whereas "link" key is the url opened when an image is clicked.

Resources