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
Related
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.
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];
}
I am trying to post some data at one of the friend from my friend list .
I am able to post some text on my friend's wall.But it fails to post the image and other data . (Presentl I can only see the text for key "message" and rest of the part does not appear in the post.
SBJSON *jsonWriter = [[SBJSON new] autorelease];
/*
Action LInks
*/
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Always Running",#"text",#"http://itsti.me/",#"href", nil], nil];
//Json Object Conversion
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
/*
Media Data in this case an image.
*/
**NSMutableDictionary *dictMedia=[NSMutableDictionary dictionaryWithObjectsAndKeys:#"image",#"type",#"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg",#"src",#"www.fizzysoftware.com",#"href", nil];
NSArray *mediaArray=[[NSArray alloc] initWithObjects:dictMedia, nil];
NSString *mediaJsonString=[jsonWriter stringWithObject:mediaArray]; // error:actionLinksStr]
//Attatchment Data :Include media data,action link etc.
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"First Title", #"name",
#"This is the subtitle", #"caption",
#"This is is description", #"description",
mediaJsonString, #"media", nil];
//Json conversion of the attachment data.
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];**
//Main parameter
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Share on Facebook", #"message",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
nil];
//Post to friend's wall, whose uid is friend_uid
[ _facebook requestWithGraphPath:[NSString stringWithFormat:#"friend_uid/feed/"] andParams:params
andHttpMethod:#"POST" andDelegate:self];
Any suggestions where I am mistaking in sending the attachment. I am able to only see the "message" part of the param in my post and none of the attachment data is shown in the post.
Thanks in advance.
You can try using the new approach to open a feed dialog and set the "to" (used to be target) parameter along with the rest of the attachments directly as params.
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
#"some facebook id", #"to",
#"http://yourpage.com", #"link",
#"http://yourpage.com/image.png", #"picture",
#"the name", #"name",
#"the caption", #"caption",
#"the description", #"description",
nil];
[_facebook dialog: #"feed" andParams: params andDelegate: self];
Here you have some documentation regarding the feed dialog.
http://developers.facebook.com/docs/reference/dialogs/feed/
If you are posting directly, you should be doing something like this:
[_facebook requestWithGraphPath:#"some facebook id/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
Doc regarding direct posts:
http://developers.facebook.com/docs/reference/api/user/#posts
Hope this helps.
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'];
}
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 ;)