Where should i put keys given by facebook in FBConnect - iphone

I want to use facebook api in my future iphone project..
I have got App id...App Secret...and api key from the facebook..
Now I want to use it in my FBConnect..
Where should I use this details in the fbConnect?

Use the appID to create the facebook object
_facebook = [[Facebook alloc] initWithAppId:kAppId];
decide what permissions you want to get
_permissions = [[NSArray arrayWithObjects:
#"read_stream", #"offline_access",nil] retain];
and then login using
[_facebook authorize:_permissions delegate:self];
also dont forget to add the URL fb[appID] to the URL Types key in the info.plist file.

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

Post a photo to a page for iOS

I am trying to post a photo to a page that the user does not own. Note that all solutions that I found from other discussion threads require the user to be administrative and get the access_token of a page with *manage_pages* permissions.
However, what I want to do is different: Using iOS SDK to upload an image to a page, which has a setting that people can upload images to it.
I try several ways, but none of them works.
Here is how I get permissions
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"photo_upload",
#"share_item",
#"status_update",
#"manage_pages",
#"user_likes",
#"publish_stream",
nil];
[fb authorize: permissions];
Here are the codes for uploading the image
NSString *uri = [NSString stringWithFormat: #"%#/photos", FBPageId];
[fb requestWithGraphPath: uri
andParams: params
andHttpMethod: #"POST"
andDelegate: self];
It kept posting the image to the user's album, which is not what I want.
I will really appreciate if anyone knows how to do it. Thank you!
I have two potential workarounds for you to try out:
Post the picture to the pages feed rather than to the {pageid}/photos.
Collect the albums for that page {pageid}/albums. Now with the correct album id, post the picture to {albumId}/photos.

Getting friends of friends with Facebook iOS SDK

Is it possible to get information about friends of my friends using facebook ios sdk?
Please.If it is possible give an example.
request with Graph api #'[friend_id]/friends" does not work.
'code' [facebook requestWithGraphPath:#"[friend_id]/friends" andDelegate:self];'code'
i try this code but it returns
Error:facebookErrDomain error 10000 where'code'
facebook = [[ Facebook alloc] initWithAppId:app_id];
NSArray *permissions = [NSArray arrayWithObjects:#"I try all permissions"];
[facebook authorize:permissions delegate:self]; 'code'
user is logged in, All information about this friend is available
I'm quite sure this is not possible, you'ld need data access privs of the friends to get their friends data. this has to do with the access rights on fb and this is good for some reasons it is like it is. even if this data protection mechanism disturbs your business idea ;)
If you want catch friend informations you must :
Alloc and Init a Facebook object
Facebook *facebookObject = [[Facebook alloc] init];
Check permissions
NSArray *permissions = [NSArray arrayWithObjects:#"publish_stream", #"offline_access",nil];
Authorize facebook
[facebookObject authorize:APP_ID permissions:permissions delegate:self];
After that you can used
[facebookObject requestWithGraphPath:#"me/friend" andDelegate:self];
In delegate methods
- (void)request:(FBRequest *)request didLoad:(id)result
You catch the result who must be a NSDictionnary.

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 :)