Non standard URLs in Post - ios

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).

Related

Facebook requests example project

Has anyone found an example project for this tutorial on facebook requests: http://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk/
Since I have already integrated a list of facebook friends a user has, can I send each a message?
You can find the actual project on GitHub, https://github.com/fbsamples/ios-3.1-howtos/tree/master/SendRequestsHowTo
If you already have a list of Facebook friends you can just send them a message. Just get a comma-separated, string representation of those friends, and pass the info to the "suggested" parameter:
NSString *friendList = #"12345, 4567";
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Check this out.", #"message",
friendList, #"suggestions",
nil];
[self.facebook dialog:#"apprequests"
andParams:params
andDelegate:self];

Facebook "FBCDN image is not allowed in stream"?

after uploading an image, i want to post it on the users wall.
Unfortunately, i get the following error within a Facebook UI:
"FBCDN image is not allowed in stream.filepath"
It seems that the value #"picture" won´t be accepted, but why?
When i NSLog the "thumbURL", its correct.
How can i fix that?
Here´s my complete method:
NSString *thumbURL = kDefaultThumbURL;
NSString *imageLink = [NSString stringWithFormat:[result objectForKey:#"link"]];
NSMutableDictionary* dialogParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"app_id",
imageLink, #"link",
thumbURL, #"picture",
#"imageName", #"name",
nil];
[appDelegate.facebook dialog:#"feed"
andParams:dialogParams
andDelegate:self];
Thanks for any help..
You need to store the image some where locally ,in a local server . due to this article
I got around this same issue by writing a page that just forwards the image data and then linking to that instead.
Yep, you're not allowed sharing images hosted by Facebook CDN servers.
There are two possible solutions:
Download and host to image on your local server.
Write a page with gets the FBCDN url, gets the image content and send it returns the image data.

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.

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.

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

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

Resources