iphone facebook publishToStream question - iphone

I'm using the iOS facebook DemoApp example to post to my profile. It works just fine. My question is how do I add a picture link to this post? The code I'm using is:
- (IBAction)publishStream:(id)sender
{
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"title",#"text",
#"http://www.link.com/",#"href",
nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"This is a name!", #"name",
#"This is a caption!", #"caption",
#"http://www.link.com/images/log1.png", #"picture",
#"This is a long description that goes on an on.", #"description",
#"http://www.link.com", #"href",
nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"api_key",
#"Share on Facebook", #"user_message_prompt",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
nil];
[facebook dialog:#"stream.publish"
andParams:params
andDelegate:self];
}
The picture will not come up. The link I use is correct. And the post succeeds. How do I get that picture link to show up?
Thanks for any and all help.

The sample app in the Facebook iOS SDK is a little outdated. I detailed the proper way to publish to a user's stream and the relevant documentation page in my answer to this SO question.

Related

Image change in dialogFeed facebook

How can I add my own picture for the feed. I have it in my application folder. I have to give my image instead of #"http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png".
- (void)apiDialogFeedUser {
currentAPICall = kDialogFeedUser;
SBJSON *jsonWriter = [[SBJSON new] autorelease];
// The action links to be shown with the post in the feed
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Get Started",#"name",#"http://m.facebook.com/apps/hackbookios/",#"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
// Dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"I'm using the Hackbook for iOS app", #"name",
#"Hackbook for iOS.", #"caption",
#"Check out Hackbook for iOS to learn how you can make your iOS apps social using Facebook Platform.", #"description",
#"http://m.facebook.com/apps/hackbookios/", #"link",
#"http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png", #"picture",
actionLinksStr, #"actions",
nil];
HackbookAppDelegate *delegate = (HackbookAppDelegate *)[[UIApplication sharedApplication] delegate];
[[delegate facebook] dialog:#"feed"
andParams:params
andDelegate:self];
}
I want to have my image over there. Please help.
The 'picture' parameter only accepts urls of already hosted pictures.
If you want to use a picture which is stored locally then you'll need to upload it first to a server and then use that url when posting to the feed.

Facebook IOS SDK Feed Post Visibility

I have this function
-(void)feed_post:(NSString *)message andDelegate:(id<FBRequestDelegate>)delegate{
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
message, #"message",
nil];
[facebook requestWithGraphPath:#"/me/feed" andParams:params
andHttpMethod:#"POST" andDelegate:delegate];
}
to post a message to the user's wall. Everything is working but the post is only visible by me. It seems that it is posting as an own private message. How should I configure the params to change the post visibility? Thanks.
This did the trick. Also I had to delete cookies.
NSDictionary *dictPrivacy = [NSDictionary dictionaryWithObjectsAndKeys:#"EVERYONE",#"value", nil];
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSString *strPrivacy = [jsonWriter stringWithObject:dictPrivacy];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
message, #"message",
strPrivacy,#"privacy",
nil];

Uploading Game Scores to Facebook in iPhone?

i am trying to access facebook in my application to submit scores for my game.. i have registered my application on fb included its api into my xcode project and i am trying to use their sample project to publish the scores using the following code but when i use this code the message is posted on my wall but not all the details are included as used in NSMutabledictionary ..what am i possibly doing wrong??
- (IBAction)publishStream:(id)sender {
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Always Running",#"text",#"http://itsti.me/",#"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"a long run", #"name",
#"The Facebook Running app", #"caption",
#"it is fun", #"description",
#"http://itsti.me/", #"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Share what on Facebook", #"user_message_prompt",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
nil];
[_facebook dialog:#"feed"
andParams:params
andDelegate:self];
}
only the SHARE ON FACEBOOK message is posted on my wall along with the name of my application and rest i am not able to figure out how to use... any help will be appreciated??
Here is a modified PublishStream function that works.
- (void)publishStream:(id)sender {
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Always Running",#"text",#"http://itsti.me/",#"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"a long run", #"name",
#"The Facebook Running app", #"caption",
#"it is fun", #"description",
#"http://itsti.me/", #"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Share on Facebook", #"user_message_prompt",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
[NSString stringWithFormat:#"I scored %d on mycoolgame, Think you can beat me? - http://bit.ly/cJtBkE", totalScore],#"message",
nil];
[_facebook dialog:#"feed"
andParams:params
andDelegate:self];
}
As pointed our by #hemant "stream.publish" is missing. That seems to be all that is missing from the DemoApp included with the Facebook SDK.

How to post to facebook from iPhone using publish.stream without the Facebook dialog method

I would simply like to use publish.stream to post to Facebook from an iPhone app but without using the UIWebview that pops up when you call the Facebook object's dialog method. How do I do this?
SBJSON *jsonWriter = [[SBJSON alloc] init]; NSDictionary *attchmentDic = [NSDictionary dictionaryWithObjectsAndKeys:
#"Foobar",#"name",
nil]; NSString *attachmentStr = [jsonWriter stringWithObject:attchmentDic]; NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Bla-bla",#"message",
attachmentStr, #"attachment",
nil];
[_facebook requestWithMethodName:#"stream.publish"
andParams:params
andHttpMethod:#"POST"
andDelegate:self]; [jsonWriter release];

iphone facebook wall posting with image map link

is possible to attach a link (image) of a google map on the side of my wallpost throug iphone?
my wall post is ok, but i've no idea how to do with the map.
Ps in my app i've implemented also mapkit, i don't know if i make a gquery with coordinate to obtain map link or i must work using the position that i have on mapkit
i've found my solution with google static maps :D
here's my code:
dialog.attachment = [NSString stringWithFormat:
#"{ \"name\":\"%# si trova a %#\"," "\"media\":[{\"type\":\"image\","
"\"src\":\"http://maps.google.com/maps/api/staticmap?size=100x100&zoom=14&markers=color:blue|label:here|%g,%g&mobile=true&sensor=false\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],}",
_facebookName, citta.text, mylat, mylong ];
to post a image use the following code (extracted from demo app
- (IBAction) publishStream: (id)sender {
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Always Running",#"text",#"http://itsti.me/",#"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"a long run", #"name",
#"The Facebook Running app", #"caption",
#"it is fun", #"description",
#"http://itsti.me/", #"href",
[NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
#"image", #"type",
#"http://www.gogle.com/", #"href",
#"http://a1.twimg.com/profile_images/457512510/iconoTwitter_bigger.gif", #"src",nil]
, nil ]
,#"media", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"api_key",
#"Share on Facebook", #"user_message_prompt",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
nil];
[_facebook dialog: #"stream.publish"
andParams: params
andDelegate:self];
}