FBStreamDialog no longer working as expected - iphone

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.

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.

Error when posting to Facebook Wall from iPhone app

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.

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 will this code publish an image to a wall using Facebook Connect?

I would like to know what this code does exactly.
- (void)dialogDidSucceed:(FBDialog*)dialog {
//[self doSomethingExciting];
FBStreamDialog *dialog2 = [[[FBStreamDialog alloc] init] autorelease]; dialog.delegate = self;
dialog2.userMessagePrompt = #"Example prompt";
dialog2.attachment = #"{\"name\":\"Facebook iPhone SDK\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\","
"\"caption\":\"Caption\",\"description\":\"Description\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],"
"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}";
// replace this with a friend's UID
// dialog.targetId = #"999999";
[dialog2 show];
}
When I run it it asks me if I want to publish on my and my friends walls, but Im not sure how this will look on the walls. Also does it publish to the users walls and then show up in their friends incoming stream, like "most recent" or does it actually post on every friends wall?
Thanks
Yes. You are posting an image to their stream.
Attachment is an escaped sequence of JSON that Facebook will pick up on and attach an image (and it looks like a link as well).
What the user will see is the image/link preconfigured as a wall post, and they will have a text box to enter their own text referred so as User Message Prompt.
Whether or not it shows up on friends streams depends on their settings, but ultimately, this is a news stream post, and thus has the potential to appear on their home page.
An other answer already explained what the code does.
This is just a tip:
Create three fake FaceBook accounts, and connect them together.
Then use them to do your testings. So you will know exactly what happens, and do all the tests you need during development without loosing all your friends.

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.