Facebook Connect Posting a Status Update - iphone

HI I have got Facebook Connect working with a functional login and logout button. So far thats it, when I press a button a I want to post something to the user. Is there something I have to authorize? What is the precise steps for this. Thank you.

If you want to publish content to User's Feed you not required to authorize user if you use Feed Dialog for any other ways you required to authorize user prior to content publishing.
For web applications/sites (which isn't the case) there is also way to leverage automatic publishing of content user liked using Like Button social plugin by providing correct OpenGraph meta tags.
You really need to read documentation for iOS SDK, especially Dialogs and Authentication and Getting Started Guide.

if you want to set his status thought your FB app without showing a dialog you could do it like this
NSString *message = #"some text";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, message,nil];
[fb requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self]; //fb here is the FaceBook instance.
and for sure you will do that after the user login and authorized the permissions .
To Authorize the permissions
if (![fb isSessionValid]) {
NSArray *permissions = [[NSArray alloc] initWithObjects:#"user_likes", #"read_stream", nil];
[fb authorize:permissions];
[permissions release];
}

Related

Facebook like button in iPhone native app

I want to implement facebook like button in my native iphone app. So that user can like my facebook page . I am already sharing facebook status updates, but am unable to implement like button.
I was unable to find any helpful resource on web.Please help.
Aaaand here's one I prepared earlier (using FBConnect, the FB api):
If you have the id of the post as postId
NSString *graphPath = [[NSString alloc]
initWithFormat:#"%#/likes",
postId];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[[delegate facebook] requestWithGraphPath:graphPath andParams:params andHttpMethod:#"POST" andDelegate:self];
of course you'd need to change how you got the Facebook singleton (I used [delegate Facebook]).

facebook dialog not sending request to friend

I am trying to use the facebook dialog to send request to my friend using the following:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Come check out my app.", #"message",
nil];
[facebook dialog:#"apprequests"
andParams:params
andDelegate:self];
the delegate - (void)dialogDidComplete:(FBDialog *)dialog { was triggered but apparently I dont see anything on my friends account. I've added him as a tester of the app through the developer account. Why is this?
From https://developers.facebook.com/docs/requests/:
User to User Requests are only available for Canvas apps, not
websites, as accepting a request will direct the user to the Canvas
Page URL of the app that sent the Request.
Do you have a canvas url specified in your app settings?
Also what does the response look like from Facebook at the completion of the dialog? It should look like:
{
request: 'REQUEST_OBJECT_ID'
to:[array of USER_IDs]
}

i want to share friend's post via graph api

I want to share some posts in facebook via graph api.
But there's no api like this. only "feed" exists.
I tried to use "me/feed" graph api action to share my friend's post(and post in page). but it's not same as i shared in facebook website. i want to know how.
source is..
NSMutableDictionary *fbArguments = [[NSMutableDictionary alloc] init];
NSString *linkURL = #"http://media.daum.net/society/others/view.html?cateid=1067&newsid=20120106140112792&p=munhwa&RIGHT_COMM=R4";
[fbArguments setObject:linkURL forKey:#"link"];
[facebook requestWithGraphPath:#"me/feed"
andParams:fbArguments
andHttpMethod:#"POST"
andDelegate:self];
[fbArguments release];
And I noticed there's no action for sharing friend's post(or photo), page's post via facebook iphone app. (so weird. don't you need this action?)
what can i do? can you help me?
Thanks.
i'v succeeded sharing photo. that is 'Link'.
source is
NSMutableDictionary *fbArguments = [[NSMutableDictionary alloc] init];
NSString *linkURL = #"https://www.facebook.com/photo.php?fbid=324225380935287&set=a.265279620163197.68309.194442110580282&type=1";
[fbArguments setObject:linkURL forKey:#"link"];
[fbArguments setObject:#"good!" forKey:#"message"];
[facebook requestWithGraphPath:#"me/feed"
andParams:fbArguments
andHttpMethod:#"POST"
andDelegate:self];
[fbArguments release];
i added message. and this is perfectly same as i shared via facebook web.
but there is one problem. this never makes back reference(trackback?).
if I share a photo via facebook web, I can see "5 shares" upper comment list, and my username is is there.
But this way, There is no my username. No trackback.
what can i do?
thanks.

Facebook Feed Dialog keeps asking for permission

I've been trying to post a link on user's wall, by using Facebook SDK for the iOS.
I'm trying the code below and it works perfectly when I don't have the Facebook App installed. But when I have it, it just ask me to authenticate and send me back to the App. It happens even just to say that I've already gave the necessary permission, but never shows the dialog to do the share.
The code is:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:#"%# %.0f%% OFF", self.offer.description,
[self.offer.price.discountPercent doubleValue] * 100], #"name",
self.offer.store, #"caption",
self.offer.imageKey, #"picture",
#"Test", #"description",
[NSString stringWithFormat:#"http://my_url.com/id%#", self.offer.offerId], #"link",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
Any idea? Thank you in advance ;)
I think this is becouse of you login/logout code. when you making an autorization request to FB, one of params you sending is how long access token must "live". Make shure it lives long anoth. Or, somewhere in the code you invalidating it. May be even losting pointer to access token or something. Make sure, that acces token you use to post is validate at the moment you posting. I suggest you to use official SDK for FB: it's really simple and without any problems. There is great tutorial how to use it: http://developers.facebook.com/docs/mobile/ios/build/

Creating a Facebook event on public FB Page using iPhone SDK Graph API

I'm trying to let users create an event on my public Facebook page via an iPhone app, and hopefully let ppl invite their friends to that event.
The idea is that the iPhone app will be able to show the users events from that page, while everyone is able to add the events.
After Authorizing with permissions: create_event and manage_pages, i'm trying to run the following code:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My Event",#"name",
PAGE_ID, #"page_id",
#"2011-11-10T13:30",#"start_time",
#"2011-11-11T13:30",#"end_time", nil];
[facebook requestWithGraphPath:[NSString stringWithFormat: #"%#/events", PAGE_ID]
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
And I get and error saying: "(#200) Permissions error".
Is it even possible? (creating an event on a page which a user doesn't own)
and if so, what am I missing?
permissions = [[NSArray alloc] initWithObjects:#"offline_access", #"user_events",#"create_event",#"rsvp_event", nil];
I hope that it is just your help.