I am developing a iPhone application in which I want to simply 'Like' my own Facebook AppID.
For Facebook integration I am using FBConnect and Graph API (https://github.com/facebook/facebook-ios-sdk/blob/master/README.mdown).
After researching, I found that I was supposed to use the following method, which I attempted to implement in the "DemoAppViewController.m" of the sample code when the 'publishStream' button was selected:
NSMutableDictionary *params = [NSMutableDictionary dictionary]; //Use an empty dictionary
[_facebook requestWithGraphPath:#"https://graph.facebook.com/163221793740496/likes"
andParams:(NSMutableDictionary *)params
andHttpMethod:#"POST"
andDelegate:(id <FBRequestDelegate>)self];
However, my FBRequest.m 'responseString' indicates: {"error":{"type":"GraphMethodException","message":"Unsupported post request."}}
What am I doing wrong and how can I make this work?
From what I understand, all I need to do is attach my accessToken to https://graph.facebook.com/163221793740496/likes. What exactly does that mean, and how is it accomplished?
Thanks in advance!
P.S. - In case there was any confusion, my post was in reference to having a user sign into Facebook with their account login via a fb like button in the application. After the user allowed the appropriate permissions, my app would 'like' the AppID with the user's account.
You can't programmatically like a page on Facebook. It would be enthusiastically abused.
Related
I would like my iPhone app to be able to post a static message to a user's friend's facebook wall. Something like it shows the static message up above, and then a place to type in friends name and shows suggested friends. Is this done through graph api, or is there a key of permissions that the POST method can use?
Looks like this might be what you are after.
From the link:
"You just have to send your friend's Facebook ID as a parameter under the key "target_id".
set a parameter under the key #"target_id" on the parameters dictionary (when invoking dialog:andParams:andDelegate: on the Facebook object).
Here you have a sample post using the new sdk (the one that uses graph api):
NSMutableDictionary* params = [NSMutableDictionary dictionary];
[params setObject:#"Some text" forKey:#"user_message_prompt"];
[params setObject:#"another text" forKey:#"action_links"];
[params setObject:#"Yet another text" forKey:#"attachment"];
[params setObject:#"SOME FACEBOOK ID" forKey:#"target_id"];
//At some point you need to create the following Facebook instance
[facebook dialog: #"stream.publish"
andParams: params
andDelegate: self];
you first need to request the friend list and then provide an interface in your app where user could select which friend's wall he want to write on... :)
afterwards, you can pass the selected friends id to the dialog you are presenting to the user... Atleast I am used to do it this way and it seems to be a pretty standard way of publishing something on user's wall...
hope it helps
In my iPhone app I only want to post a message to a Facebook App page.
I have downloaded and implemented the facebook-sdk and I have looked at the demo-app.
What I have read is that It looks like that I have to do three things:
- login to facebook (done!)
- get an access token
- post the message (Is this the same as posting to my own wall)
Is using the graph-api's the right track?
Can anyone help me on the right track.
may be this solve your problem
- (void) SendTextMsg
{
NSMutableDictionary *param = [NSMutableDictionary dictionary];
[facebook dialog:#"feed" andParams:param andDelegate:self];
}
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];
}
I have integrated the facebook in to my application, From the FB i will be getting the userid and the name of the user and passing it to my own service that will do the validation and allows the respective user to get in to the system. I have got the userid and username from the FB and passed it my service that will do the validation,it allows the user to enter in to app, but my problem is once i logged in , how can i log out from the FB ?
Please let me know your ideas.
Thanks
If you are using the new facebook sdk, then us
[facebook logout:delegate]
Being facebook your Facebook object,and delegate an FBSessionDelegate.
If all goes well your delegate will be called on -(void)fbDidLogout;
That depends on which library you use to connect to facebook.
But I guess that you have a FBSession class that has a logout method...
That logout method also calls deleteFacebookCookies that you could also directly call depending on your needs...
Hope that helps.
If you are using old facebook sdk,then use this code for logout.make FBSession class object and code like this. [FBSessionclassobject logout];
it will delete all FacebookCookies.
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....