Objective c Facebook Graph API上载照片问题
我已经在网上搜索过了,并下载了Facebook SDK来尝试上传照片的功能,它在那里起了作用。 完全相同的代码到我的应用程序,它不工作。 请帮忙??? 这是我的密码:Objective c Facebook Graph API上载照片问题,objective-c,xcode,facebook,upload,photos,Objective C,Xcode,Facebook,Upload,Photos,我已经在网上搜索过了,并下载了Facebook SDK来尝试上传照片的功能,它在那里起了作用。 完全相同的代码到我的应用程序,它不工作。 请帮忙??? 这是我的密码: - (IBAction)pushUpload:(id)sender { NSString *path = @"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"; NSURL *url = [NSURL URLWithString:path
- (IBAction)pushUpload:(id)sender {
NSString *path = @"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
[_facebook requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
[img release];
[loadingIcon startAnimating];
}
如你所见,我已将加载图标放在那里,以便在其上载时开始制作动画。。在didload请求下,当它成功上传时,我执行了stopanimating命令
-(void)request:(FBRequest *)request didLoad:(id)result{
[loadingIcon stopAnimating];
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"owner"]) {
[loadingIcon stopAnimating];
UIAlertView *alert;
alert = [[UIAlertView alloc] initWithTitle:@""
message:@"Photo uploaded."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
} else {
// [self.label setText:[result objectForKey:@"name"]];
}
}
问题是,加载图标只是保持动画,没有错误,但仍然没有图片上传到我的facebook帐户。你知道为什么吗
以下是my.h文件中的代码:
@界面上载PhotosViewController:
UIViewController(FBRequestDelegate、FBDialogDelegate、,
FBSessionDelegate){
@财产(只读)Facebook*Facebook
- (iAction)推送上载:(id)发送方
- (iAction)推选:(id)发送方
另一件需要注意的事情是,(FBRequestDelegate、FBDialogDelegate、FBSessionDelegate)没有颜色指示器,而应该有。这有问题吗?检查您是否在.h文件中写入了Facebook的代理。 还要检查此代码 这对我很管用
NSString *string=@"Images of me";
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"My name", @"name",
string, @"description", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"This is image",@"description",
@"Share on Facebook", @"user_message_prompt",
//actionLinksStr, @"action_links",
attachmentStr, @"attachment",
/*Your image here", @"picture",
nil];
试试这个代码
希望它能帮助您……检查您是否在.h文件中写入了Facebook的委托。 还要检查此代码 这对我很管用
NSString *string=@"Images of me";
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"My name", @"name",
string, @"description", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"This is image",@"description",
@"Share on Facebook", @"user_message_prompt",
//actionLinksStr, @"action_links",
attachmentStr, @"attachment",
/*Your image here", @"picture",
nil];
试试这个代码
希望它能帮上忙……试试我/订阅,而不是我/照片
[_facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
尝试我/订阅,而不是我/照片
[_facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
我认为这是因为你没有正确地声明你的协议。它们放在尖括号里,而不是括号里
@interface UploadPhotosViewController : UIViewController<FBRequestDelegate, FBDialogDelegate, FBSessionDelegate>
@界面上传PhotosViewController:UIViewController
我认为这是因为您没有正确声明协议。它们放在尖括号中,而不是括号中
@interface UploadPhotosViewController : UIViewController<FBRequestDelegate, FBDialogDelegate, FBSessionDelegate>
@界面上传PhotosViewController:UIViewController
Hi,感谢您的回复,但不幸的是,它仍然无法与您的代码配合使用…>Hi,感谢您的回复,但不幸的是,它仍然无法与您的代码配合使用…>