Error when posting to Facebook Wall from iPhone app - iphone

I'm building an app that allowed me to post to a user's wall on facebook. This functionality was working fine up until recently, when for some reason, if I try to post to the wall on facebook, I am now getting the error:
"The post's action links must be valid url's. You can see this because you are one of the developers of the app."
Does anyone know why this is happening? I did not change the code at all in my app, and after searching the web, found others are also having the same problem when trying to post to their facebook wall, but without a solution. Does anyone know what is wrong here, and how to fix it?

How old is the code that you are working with? And, are you using OAth 2.0? If you're not you should, because I believe OAuth 1.0 has been deprecated by Facebook and is only supported for "legacy" applications.

I found the solution to my problem. The relevant code that was causing the problem is:
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your message:";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"Check out this great restaurant!\",\"href\":\"/\",\"caption\":\"%#\",\"description\":\"%# \r %#, %# %#\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.muslimgreenpages.ca/images/gethalal/GetHalal_IC_B_03.png\",\"href\":\"http://www.gethalalapp.com/\"}]}",
restaurantObj.name, restaurantObj.address, restaurantObj.city, restaurantObj.provinceState, restaurantObj.phoneNumber];
dialog.actionLinks = #"[{\"text\":\"Download GetHalal!\",\"href\":\"http://www.gethalalapp.com/\"}]";
[dialog show];
_posting = NO;
[_session logout];
}
In my dialog.attachment, I did not provide a value for the href parameter, so I simply removed it, and everything worked! Thanks very much mdominick for trying to help.
Take care.

Related

Sharekit2.0 could not post together "URL-linked text, image" information to facebook wall

I'm upgrading from old sharekit to latest Sharekit2.0.
Ultimately I need to reach this on Facebookshare: https://s3-ap-southeast-1.amazonaws.com/eight29/demo.png
In old sharekit, I can do that by dialog.attachment (FBStreamDialog) as shown as below. However, in latest version, this function is missing.
BStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = #"Post Item to Facebook";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"example\",\"href\":\"http://apps.facebook.com/example/?%d\",\
How can make it?
Thanks!
Liang
FBStreamDialog is not technically a part of ShareKit, but it belongs to Facebook-ios-sdk, which happens to be used in ShareKit.
FBStreamDialog no longer exists in FB's sdk, and other FBDialog family classes are deprecated. I suggest you to use their graph api, check "publishing" section for all possible parameters. Hopefully some will suit your purpose.
As for implementation, check SHKFacebook's - (void)doSend method. You can then subclass SHKFacebook and implement your own.

FBStreamDialog no longer working as expected

I am using an FBStreamDialog to display a custom prompt, capture a text message and then display that message, along with an MP3 file on a chosen Facebook friend's wall. The code has been working fine for the last 6 months in my live app. This week, however, it has stopped working. It can only be the result of a recent change in how Facebook responds to the function calls (I've logged a bug:
https://developers.facebook.com/bugs/344519698917066browse=search_4f611f5d302a37460391579).
Has anyone else encountered this problem and is there an alternative I can use without having to recode the entire FB connection stuff?
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your special message:";
dialog.attachment = [NSString stringWithFormat:#"{ custom string stuff here"}]}", friendName, #" "];
FB support response to this says I should just install a later version of the SDK and that they can find no reference to FBStreamDialog! I think this is poor when app developers have live products.

How to do string formatting in Objective-C?

I am trying to post text from my iPhone app to my wall on Facebook. Everything works fine, however, my problem is that I am not sure how to format the text. I would like to show the user the name, address, city, state, and phone number of the restaurant they are viewing on the app. Here is my relevant code:
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your message:";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"%# got straight A's!\",\"href\":\"http://www.example.com/\",\"caption\":\"%# must have gotten real lucky this time!\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.abc.png\",\"href\":\"http://www.example.com/\"}]}",
_facebookName, _facebookName];
dialog.actionLinks = #"[{\"text\":\"Download GetHalal!\",\"href\":\"http://www.example.com/\"}]";
[dialog show];
}
I would like to show the user the restaurant information in the dialog.attachment variable, such that the output on the facebook wall looks like this:
restaurant.name
restaurant.address
restaurant.city, restaurant.state
restaurant.phoneNumber
My problem is, the text above appears to be in JSON format. The restaurant object is available in the class, and I'd like to include it in the code above, but I don't know how. Can anyone show me how to do this?
Use a JSON library:
https://stackoverflow.com/questions/286087/best-json-library-to-use-when-developing-an-iphone-application
Also, check the Facebook sdk for iOS:
http://developers.facebook.com/docs/guides/mobile/#ios
The accepted answer in this StackOverflow post has the code you need, with JSONfragment:
How to post a message with attachment in Facebook?
(note that, in this case, the library used is http://code.google.com/p/json-framework/ )

How to give extended permissions in FBConnect with REST API in iPhone

I have developed an iPhone application, which is communicating data with faceBook. Initially I was only able to get basic information of user from Facebook. To post to a user's wall, I learnt about giving extended permission 'publish_stream', hence I added following code snippet:
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.permission = #"status_update";
[dialog show];
[self getFacebookName];
}
And made necessary changes in the FBPermissiondialog class file.
Now this is allowing me to post to my wall, but it shows two separate dialogs for permissions, first to access user's basic information, and second for publishing permission. I want to have all permissions in a single pop-up. Also, I am using FBRequest to post to Facebook, not FBStreamDialog (as I dont want the UI for posting).
Please help me with this, I badly need to resolve this issue soon.
Thanks in advance.
In FBLoginDialog.m file
- (void)loadLoginPage {
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
#"1", #"fbconnect", #"touch", #"connect_display", _session.apiKey, #"api_key",
#"fbconnect://success", #"next",#"user_photos,photo_upload",#"req_perms",nil];
[self loadURL:kLoginURL method:#"GET" get:params post:nil];
}
add "req_perms" key to the dictionary as shown above.
Hope this will solve your problem :)

Submitting a link via iPhone -> Facebook Connect

I'm trying to post links through the iPhone facebook connect without using the feed control. I want to simulate how the publish a story works on facebooks website, where I pass a link, and it returns back an image, story title, and a link. Right now I only know how to use the feed control, but I'm thinking there has to be a way to use possibly stream.Publish or showDialog, just not really sure which..
Anyone have any experience with this?
Use the facebook demo app.
in the SessionViewController, add this to get extended permission:
- (void)askPermission:(id)target {
FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.permission = #"publish_stream";
[dialog show];
}
Then you need a method to publish the stream. They don't say exactly what data to send. But whateer it is you package it in a dictionary. Since it is a URL, a good guess would be an NSString. You can get more from the API page
I found 5 that might work:
Feed.publishActionOfUser
Feed.publishStoryToUser
Feed.publishTemplatizedAction
Feed.publishUserAction
Also there is:
Links.post
But you'll have to figure it out, depending on what you want to do. You also need to kow the key. I picked url
- (IBAction)sendURL:(id)target{
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:urlString forKey:#"url"];
FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
[uploadPhotoRequest call:#"Links.post" params:args];
}
I've left some args out, but you get the idea. I;m not sure exactly what one you want, so you'll have to research the method calls.
Hope this helps.