Facebook iOS Integration - iphone

I have recently implemented the Facebook functionality to post an URL as explained in iOS Facebook Development
It's the same as explained.
After I've signed up on Facebook and set my app key, I started the iPhone simulator and authorized as explained on Facebook. After that the Mobile Safari didn't jump back to my app (Because I don't want Facebook to jump back. Later I want to do that calling a webpage by my own). So I just started it again (activated because of iOS 4.2).
After that, I switched to the where I post a default URL.
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSString *communityURL = #"http%3A%2F%2Fwww.google.com";
[params setObject:communityURL forKey:#"link"];
[facebook dialog:#"feed" andParams:params andDelegate:self];
Normally it should bring up a dialog with this parameters, but it just showed an error:
This page contains the following errors:
error on line 25 at column 35: xmlParseEntityRef: no name
Below is a rendering of the page up to the first error.
When I debug into the method which calls the dialog, I got the URL, which will be called.
When executing this URL in a web browser, it works.
Why doesn't it work?
What's wrong?

i didn't figure out what it was, but i came up with an other solution.
I now use ShareKit. It's easy to use and it handles all alone. I try to post some sourcecode snipets asap.
For those, who have the same problem and don't want to use another API, try to do what ever the facebook documentation tells you.
Br
Nic

ok what I did is simply add
NSURL *url = [NSURL URLWithString: #"http://www.google.com"];
SHKItem *item = [SHKItem URL:url title:#"Share Item with Google url ;)"];
// Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showFromTabBar:self.tabBarController.tabBar];
And that's what I do.
If someone needs help, please feel free!!
Br
Nic

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

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

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/

iPhone Facebook image upload not working, tried everything

I'm losing my mind over trying to get Facebook SDK for iPhone to upload UIImage.
Here's what I'm doing:
1) Creating facebook property:
facebook = [[Facebook alloc] initWithAppId:#"111111111"];
2) Calling authorize:
[facebook authorize:[NSArray arrayWithObjects:#"publish_stream", nil] delegate:self];
3) Setting params:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:image, #"picture", nil];
4) Calling post:
[facebook requestWithMethodName:#"photos.upload" andParams:params andHttpMethod:#"POST" andDelegate:self];
When loging in I get the authorize dialog. When trying to upload I receive error 101, Invalid API Key. I've copied the key from FB, I've included it as shown above and I've also included it in .plist (fbAPI_KEY). What the hell am I still missing here? When asked to authorize it did show the name of the app just fine so the key must be correct. I can also post feeds and they appear on users wall, but images just won't upload.
That's a bit weird, I've got the exact same four lines of code which work fine for me. (Although, your app id is a bit shorter than it should be, mine is roughly twice that size).
One thing you may be forgetting about: when are you using each line? You should wait till each of the previous tasks is completed by using the facebook delegates, eg:
- (void)fbDidLogin; //part of the <FBSessionDelegate> protocol
Use these methods to control when the next part of the uploading process should occur, and check for errors along the way. You may be trying to send the photo before the login process has actually finished - use the delegate methods to prevent this.
I think you have to use graph API for uploading images
Check Out:
Ref URL: http://www.raywenderlich.com/1626/how-to-post-to-a-users-wall-upload-photos-and-add-a-like-button-from-your-iphone-app
Hope this helps....