Facebook like button in iPhone native app - iphone

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

Related

FaceBook app request is shown on website only, but not on FB app

I'm sending an app request from my iphone app, using this code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Join my app", #"message", [NSString stringWithFormat:#"%#", [[filteredContacts objectAtIndex:path] valueForKey:#"id"]] ,#"to",
nil];
[facebook dialog:#"apprequests"
andParams:params
andDelegate:self];
while [[filteredContacts objectAtIndex:path] valueForKey:#"id"] returns a facebook ID value.
When a FB friend of mine gets the request he can see it in the notifications section on his facebook - but only on the website itself.
When trying to find it in the facebook iphone app - it's just not there. also, it's not found on the mobile site.
How can it be posible that I see the notification on the website only?
Well the answer was very simple -
I should have define the app as a mobile app when I created it as a FB app.

Facebook Connect Posting a Status Update

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];
}

How to post on user's wall indicating an app was installed?

http://developers.facebook.com/docs/reference/api/post/ doesn't seem to give a clue about it. Would "Install(ed)" be an action? If the feed is something like " installed on iPhone", how to make the to be a link such that the user can tap on it so to lead the user to App Store?
I know the API to use, something like the following. But I just don't know what are the params that should be there for the above feed.
NSMutableDictionary* params = [[NSMutableDictionary alloc] initWithCapacity:1]
[params setObject:username forKey:#"name"];
[params setObject:#"Description" forKey:#"description"];
[facebook requestWithGraphPath:#"me/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
You can get all info of setting the facebook ios sdk with a screenshot of a post..
http://developers.facebook.com/docs/mobile/ios/build

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.

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.