我已经制作了一个应用程序,在我的应用程序中,我集成了Facebook以共享信息。
为了整合Facebook,我在应用程序中使用了Graph API。
现在,在我的应用程序中,我想要上传照片到用户的墙上。
我已经使用以下代码上传照片到用户的墙上。
// 上传照片的代码
- (void)uploadPhoto:(id)sender {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Image1" ofType:@"jpg"];
NSString *message = [NSString stringWithFormat:@"I think this is a Great Image!"];
NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addFile:filePath forKey:@"file"];
[request setPostValue:message forKey:@"message"];
[request setPostValue:_accessToken forKey:@"access_token"];
[request setDidFinishSelector:@selector(sendToPhotosFinished:)];
[request setDelegate:self];
[request startAsynchronous];
}
- (void)sendToPhotosFinished:(ASIHTTPRequest *)request {
// Use when fetching text data
NSString *responseString = [request responseString];
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSString *photoId = [responseJSON objectForKey:@"id"];
NSLog(@"Photo id is: %@", photoId);
NSString *urlString = [NSString stringWithFormat:
@"https://graph.facebook.com/%@?access_token=%@", photoId,
[_accessToken stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURL *url = [NSURL URLWithString:urlString];
ASIHTTPRequest *newRequest = [ASIHTTPRequest requestWithURL:url];
[newRequest setDidFinishSelector:@selector(getFacebookPhotoFinished:)];
[newRequest setDelegate:self];
[newRequest startAsynchronous];
}
但是,这里我得到的响应字符串是{"error":{"message":"应用程序验证错误。","type":"OAuthException"}}和照片id为:(空)
并且图像未上传到用户的墙上。 因此,请告诉我如何解决它。