iphone : FBConnect Auto post to user wall - iphone

i want to auto post to a user wall from my iphone applications ( without that "publish" "skip" dialog box ). how i can do that ?

the following should be called in the class that implements FBSessionDelegate and FBRequestDelegate:
Facebook *_facebook = [[Facebook alloc] initWithAppId:kAppId];
NSArray *_permissions = [[NSArray arrayWithObjects:
#"read_stream", #"offline_access",nil] retain];
[_facebook authorize:_permissions delegate:self];
And that is the call for fb post (should be used in the same class):
NSString *message = #"This is the message I want to post";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
message, #"message",
nil];
[_facebook requestWithMethodName:#"stream.publish"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
If you want to post a message on the wall of other user you should include "uid" parameter in your params dictionary. Please consult http://developers.facebook.com/docs/reference/rest/stream.publish/
P.S. There are all the necessary examples in the iPhone Facebook connect SDK sample code, so please do not afraid to investigate just a little bit ;)

Related

How to make a friend request with facebook ios sdk?

i'm using the facebook iOS sdk.
I need to send friend requests between users of facebook, from an iOS app.
I know that can not be sent via graph API. I'm trying to through dialog of facebook i do not know how.
Can anyone help me?
This is my code:
Facebook *face = [[Facebook alloc] initWithAppId:#"APP_ID" andDelegate:self];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"user_id", #"id",
nil];
[face dialog:#"me/friends"
andParams:params
andDelegate:self];
With this code i get a dialog with this text: "The page you requested was not found"
Ok I found a solution.
I have created a NSMutableDictionary to make a "appRequest" with their corresponding parameters but finally indicated that the type of dialogue is a "friends".
It's a strange solution but it works.
Facebook *face = [[Facebook alloc] initWithAppId:FBSession.activeSession.appID andDelegate:nil];
face.accessToken = FBSession.activeSession.accessToken;
face.expirationDate = FBSession.activeSession.expirationDate;
if ([face isSessionValid]){
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My Title", #"title",
#"Come check out my app.", #"message",
userId, #"id",
nil];
[face dialog:#"friends"
andParams:[params mutableCopy]
andDelegate:nil];
}
This may help you
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys: message, #"message", title, #"title", nil];
[[self facebook] dialog: #"apprequests"
andParams: [params mutableCopy]
andDelegate: delegate];
See this question for further details and also this document.

Post image with the old Facebook sdk

I want to post an image from my iPhone app directly to my wall. with out using an image url, with the actual UIImage or NSData.
On the recent FacebookSDK, I can post like:
[FBRequestConnection startWithGraphPath:#"me/photos"
parameters:params ..
and pass NSData of the image in params
but for older version FBConect.h can I have similar option? the one I know so far is by passing the image url as part of the parameters dictionary.
Thanks,
you can post image on your facebook timeline Wall like this way may be its helps you First you need to get permission to post Photo on wall in yourViewDidLoad Method like:-
NSArray* permissions = [NSArray arrayWithObjects:#"publish_stream", #"user_photos", nil];
[facebook authorize:permissions];
now to Post image At your Button Click or your logic like:-
-(IBAction)ActionPostWallPhoto
{
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
ImageView.image, #"picture",
nil];
[facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}

How to post photos to facebook iphone fbconnect

Hi I'm using FBConnect to post to facebook, now I need to post photos from library or taken with the cam, does anyone has a clue how to do this ?? I've searched in google but I can't find a piece of code that works for me. I've found this method:
FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
[uploadPhotoRequest call:#"photos.upload" params:args];
but in my fbconnect i have this one instead: (I think the version of the api is different)
[_fbRequest call:(NSString *) params:(NSDictionary *) dataParam:(NSData *)];
Also I'm using this method to post to the wall:
- (void)postToWall { FBStreamDialog* dialog = [[[FBStreamDialog
alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your message:";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"%# Esta conectado desde TravelFan iPhone App\",\"caption\":\"Viajar te cambia la vida\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.travelfan.com.mx/content/templates/default/images/logo_travel.jpg\",\"href\":\"http://www.travelfan.com.mx/\"}]}",
_facebookName];
dialog.actionLinks = #"[{\"text\":\"Obten TravelFan
App!\",\"href\":\"http://www.travelfan.com.mx/\"}]"; [dialog show];
}
In this method I can send an image but not as a photo its just for the app logo and its an attachment.
Can anyone tell how to post photos to the wall pls ??
Any help is apreciated XD.
You can now post photos on your wall with requestWithGraphPath method as follows.
NSData *yourImageData= UIImagePNGRepresentation(yourImage);
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Your text with picture", #"message", yourImageData, #"source", nil];
[facebook requestWithGraphPath:#"/me/photos" andParams:params andHttpMethod:#"POST" andDelegate:self];
The requestWithGraphPath method is non-blocking - meaning it will complete before the photo is actually uploaded. You'll know when the photo is finished uploading by implementing the following in your FBRequestDelegate

how to get facebook friend list using new graph API

i am currently develop an app in which i need to add friend's from facebook friend list using new facebook graph API.
This is my code:
_permissions = [[NSArray arrayWithObjects:
#"read_stream", #"publish_stream", #"offline_access",#"read_friendlists",nil] retain];
[facebook authorize:_permissions];
facebook = [[Facebook alloc] initWithAppId:#"fbid" andDelegate:self];
[facebook requestWithGraphPath:#"me" andDelegate:self];
[facebook requestWithGraphPath:#"me/friends" andDelegate:self];
NSMutableDictionary*params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"4",#"uids", #"name", #"fields", nil];
[facebook requestWithMethodName:#"user.getInfo" andParams:params andHttpMethod:#"GET" andDelegate:self];
but every time it give me error in console
please help me...
Here you have a code sample that fetches the friends info:
[facebook requestWithGraphPath:#"me/friends"
andParams:[ NSDictionary dictionaryWithObjectsAndKeys:#"picture,id,name,link,gender,last_name,first_name",#"fields",nil]
andDelegate:self];
Remember to:
implement the proper delegate methods
You must call authorize before fetching the friends information. This way the user will be able to login first.
I hope this helps, cheers
I think you should swap. Otherwise it's not working.
this is correct way:
facebook = [[Facebook alloc] initWithAppId:#"fbid" andDelegate:self];
[facebook authorize:_permissions];
$friend_list =json_decode(file_get_contents("https://graph.facebook.com/$uid/friendlists?access_token=$access_token"),true);
$friend_list_array = $friend_list['data'];
foreach($friend_list_array as $key=> $value){
$inner_array_name[$value['id']][]=$value['name'];
}

Tagging Photos via Facebook GraphAPI

Facebook recently added photo-tagging capabilities to its Graph API:
http://developers.facebook.com/blog/post/509/
I am using FbConnect on iPhone to upload a picture and tag my page inside it.
So, my first call is:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
self.imageToPost, #"picture",
#"My caption!", #"name", #"tags",
nil];
[self.theFacebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
This correctly returns:
{
id = 2092859844825;
}
Then I make another call:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
FACEBOOK_PAGE_ID,#"to",
#"160",#"x",
#"240",#"y",
nil];
[self.theFacebook requestWithGraphPath:[NSString stringWithFormat:#"%#/tags",photoId]
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
Then I get:
{contents = "OAuthException"}
{contents = "(#121) Invalid photo id"}
But what ID does it expect from me?
Submitting the same request in GET method, it doesn't give the error, so I think the id is correct. Any ideas??
What permissions do you have set? Check you have the user_photos permission