I've problem with Facebook SDK for iOS - ios

NSLog(#"%#",selectedImage);
if (self.selectedImage != nil) {
UIImage *img = self.selectedImage;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
#"iOS Apps with FBConnect",#"caption",
nil];
[facebook requestWithGraphPath:#"me/photos/Wall"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
[img release];
}
I've this code.,
I use Facebook graph API for post photo to my wall.
but Photo has been upload to other album
Can I select album to upload photo ??
or
I'd like my photo upload into "Wall Photos" album ??

Related

Facebook SDK loads default image and not image from my profile, why?

I've got these facebook permissions set in my app:
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"user_games_activity",
#"friends_games_activity",
#"publish_actions",
#"user_photos",
nil];
[[myDelegate facebook] authorize:permissions];
I'm making a request like so :
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"name,picture",#"fields",nil];
[[delegate facebook] requestWithGraphPath:#"me" andParams:params andDelegate:self];
And handling the response like :
else if([request.url rangeOfString:#"me"].location != NSNotFound)
{
NSString *username = [result objectForKey:#"name"];
NSLog(#"We think the username is %#", username);
helloGreeting.text = [NSString stringWithFormat:#"Hello %#", username];
NSString *pictureUrl = [result objectForKey:#"picture"];
NSLog(#"Now loading image [%#]", pictureUrl);
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:pictureUrl]];
profilePhoto.image = [UIImage imageWithData:data];
}
The log output I get is :
2012-06-26 15:10:49.002 FacebookIntegrator[10549:f803] We think the username is James Elsey
2012-06-26 15:10:49.003 FacebookIntegrator[10549:f803] Now loading image [http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif]
Question : Why does it obtain a default generic facebook icon rather than my own profile picture? Using the same access tokens on the Graph Explorer I can get to my profile picture image URL
The documentation for user_photos states :
Provides access to the photos the user has uploaded, and photos the
user has been tagged in
User profile picture do not require user_photos permissions. Picture is likely coming from facebook cache, you should use following url for picture.
http://graph.facebook.com/<facebook id>/picture

Upload image to facebook using default dialog

I'm trying to upload an image to facebook using the iOS SDK from Facebook.
To upload an image, I'm doing following:
-Upload image to a private server in order to get the image URL.
-Open facebook dialog with "feed" in order to upload a comment to facebook wall.
My goal is to avoid using a private server to upload the picture and get the URL, in order to upload the image to facebook directly from iPhone.
I've been googling and I found several solutions to upload images directly to facebook, but is without using the default dialog that includes the SDK.
Is any way to upload images directly from device, using the FB dialog object? Is not an option for me to make the Views to replace the dialog.
Thanks in advance.
As far this is my code to publish on facebook:
+(void)composeFacebookWithImageUrl:(NSString *)imageURL image:(UIImage *)image delegate:(id)delegate
{
Facebook *_facebook;
_facebook = [[[Facebook alloc] initWithAppId:kAppId andDelegate:delegate] autorelease];
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Always Running",#"text",#"http://itsti.me/",#"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"Ragdoll", #"name",
#"The Ragdoll maker app", #"caption",
#"Share with your friends", #"description",
#"http://www.im2.es/", #"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Share on Facebook", #"user_message_prompt",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
#"touch",#"display",
imageURL, #"picture",
nil];
[_facebook dialog:#"feed"
andParams:params
andDelegate:delegate];
}
Thanks.
Have you looked into ShareKit? I'm using it to share images in my apps and it works great.
https://github.com/ShareKit/ShareKit

Add Image to Facebook Wall

I am trying to implement a previous answer. Here is the code recommended:
-(void) postImageToFB:(UIImage *) image
{
NSData* imageData = UIImageJPEGRepresentation(image, 90);
Facebook* fb = [(uploadPicAppDelegate *)[[UIApplication sharedApplication] delegate] facebook ];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[fb accessToken],#"access_token",
#"message text", #"message",
imageData, #"source",
nil];
[fb requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
But I am getting a error not found on the term: uploadPicAppDelegate
I can't find this in the Facebook sdk or a search of the web (other than additional similar code). Is this a custom created data type --or -- am I missing a file that needs to be imported?
Thanks.
In your params dictionary the value for #"source" should be a link for the picture and not a NSData object.

iOS dev: Problem with uploading UIImage to facebook album

please check my code:
Here i'm trying to upload screenshot to facebook album, but that doesnt works
CGImageRef screen = UIGetScreenImage();
self.image = [UIImage imageWithCGImage:screen];
CGImageRelease(screen);
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
self.image, #"picture",
nil];
[self.facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
self.image is ok, it is used in other parts of the code and everything looks nice. if i set up self.image for ex for [uiimage imagenamed#"example.png""] everything works nice. the different is that one uiimage exists on in memory and another both in memory and device.
what can bee wrong?
thanks
solved. the problem was the wrong way of making a screenshot.

Upload photo to a facebook fan page

here's my code keypoints that I'm using in order to upload photo to my fan page
_permissions = [[NSArray arrayWithObjects:#"read_stream", #"offline_access", #"publish_stream", #"manage_pages", #"user_photos", #"friends_photos",nil] retain];
[_facebook requestWithGraphPath:#"/me/accounts" andDelegate:self];
I parse the page access_token from results and use it for next requests impersonating page, and I can successifuly parse out page owner info from the result, so I guess my access_token is ok
- (IBAction)getUserInfo:(id)sender {
_facebook.accessToken = self.pageAccessToken;
[_facebook requestWithGraphPath:#"me" andDelegate:self];
}
But If I try to upload photo to my page album like this:
- (IBAction)uploadPhoto:(id)sender {
NSString *path = #"http://dl.dropbox.com/u/xxxxxxx/Icon.png";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
nil];
_facebook.accessToken = self.pageAccessToken;
[_facebook requestWithMethodName:#"photos.upload"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
//or like
// [_facebook requestWithGraphPath:#"/me/photos" ...
// [_facebook requestWithGraphPath:#"/<PAGE_ID>/photos" ...
// [_facebook requestWithGraphPath:#"/<ALBUM_ID>/photos" ...
[img release];
}
I always get error:
Error Domain=facebookErrDomain Code=190 "The operation couldn’t be completed. (facebookErrDomain error 190.)" UserInfo=0x15fca0 {request_args=(
{
key = method;
value = "photos.upload";
},
{
key = sdk;
value = ios;
},
{
key = "sdk_version";
value = 2;
},
{
key = "access_token";
value = "1939755xx612731|8ceab6c65ce0194d079f41ef-1068726246|3x2697618282|xdSRakxsdjezx9N1dnr9cRe6ICk";
},
{
key = format;
value = json;
}
), error_msg=Invalid OAuth 2.0 Access Token, error_code=190}
}
(note: i've modified slightly access_token just for protection)
Hey jackiedigital, I this the "manage_pages" permission is only compatible with the Graph API.
Check out the Last permission on this page: http://developers.facebook.com/docs/authentication/permissions/

Resources