How to give extended permissions in FBConnect with REST API in iPhone - 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 :)

Related

Is it possible to bypass the share dialog and post directly to Facebook? in share kit

i Successfully bypass the Twite dialog and post directly to Twitter In ShareKit using following Code
SHKTwitter *twitter = [SHKTwitter new];
[twitter authorize];
SHKItem *item = [SHKItem new];
[item setCustomValue:#"i am tweeting" forKey:#"status"];
twitter.item = item;
[twitter send];
item.shareType = SHKShareTypeText;
item.text = #"hi";
But now also want to apply it to Facebook. plz help me
i use above code from here
Thanks In Advance
FBGraph is much better way to use facebook API in your app.
download the FBGraph Api documents folder then add it to in your folder.
and read the instruction on facebook developer site http://developers.facebook.com/docs/reference/api/.
this is the sample code - sample code
and let me know if you have any query about it.
No it's possible to imitate the Share dialog directly.
You can use the /ID/feed connection but the user status update will appear as "via your 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];
}

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.

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.

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.