0
Facebookの壁に写真をアップロードするiPhoneアプリを開発するつもりです。 (ヌル)グラフAPIを使用してFacebookの壁に写真をアップロードする際にエラーが発生しました
- (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];
}
- (void)getFacebookProfileFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
NSLog(@"Got Facebook Profile: %@", responseString);
NSString *likesString;
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSArray *interestedIn = [responseJSON objectForKey:@"interested_in"];
if (interestedIn != nil) {
NSString *firstInterest = [interestedIn objectAtIndex:0];
if ([firstInterest compare:@"male"] == 0) {
[_imageView setImage:[UIImage imageNamed:@"depp.jpg"]];
likesString = @"dudes";
} else if ([firstInterest compare:@"female"] == 0) {
[_imageView setImage:[UIImage imageNamed:@"angelina.jpg"]];
likesString = @"babes";
}
} else {
[_imageView setImage:[UIImage imageNamed:@"maltese.jpg"]];
likesString = @"puppies";
}
NSString *username;
NSString *firstName = [responseJSON objectForKey:@"first_name"];
NSString *lastName = [responseJSON objectForKey:@"last_name"];
if (firstName && lastName) {
username = [NSString stringWithFormat:@"%@ %@", firstName, lastName];
} else {
username = @"mysterious user";
}
_textView.text = [NSString stringWithFormat:@"Hi %@! I noticed you like %@, so tell me if you think this pic is hot or not!",
username, likesString];
[self refresh];
}
しかし、彼女を: 私はここ
- (void)rateTapped:(id)sender {
NSString *likeString;
NSString *filePath = nil;
if (_imageView.image == [UIImage imageNamed:@"angelina.jpg"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"angelina" ofType:@"jpg"];
likeString = @"babe";
} else if (_imageView.image == [UIImage imageNamed:@"depp.jpg"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"depp" ofType:@"jpg"];
likeString = @"dude";
} else if (_imageView.image == [UIImage imageNamed:@"maltese.jpg"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"maltese" ofType:@"jpg"];
likeString = @"puppy";
}
if (filePath == nil) return;
NSString *adjectiveString;
if (_segControl.selectedSegmentIndex == 0) {
adjectiveString = @"cute";
} else {
adjectiveString = @"ugly";
}
NSString *message = [NSString stringWithFormat:@"I think this is a %@ %@!", adjectiveString, likeString];
NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addFile:filePath forKey:@"file"];
//[request setFile:filePath withFileName:@"myphoto.jpg" andContentType:@"image/jpeg" forKey:@"photo"];
[request setPostValue:message forKey:@"message"];
[request setPostValue:_accessToken forKey:@"access_token"];
[request setDidFinishSelector:@selector(sendToPhotosFinished:)];
[request setDelegate:self];
[request startAsynchronous];
}
ここ
私はidがある写真を得たthis code
使用しています次のエラーが発生しました
ここではコンソールにエラーが表示されます:Got Facebook Photo:{"error":{"message": "#803}リクエストしたエイリアスの一部が存在しません: ) "、" type ":" OAuthException "}}
私はこれをさまざまなアプリケーションIDを変更して試しましたが、私の問題は解決しません。私はこれを達成するのに役立ち 誰でも.........事前に
おかげで...
第2のものについてはわかりません。しかし、最初に動作します。 –
ご返信ありがとうございます: "urlPhoto"カメラで撮影したローカル写真をアップロードしようとしていますが、フォームURLではありません。 – Vijay
FB壁に写真を掲載したい。別の方法で、最初の写真を壁にアップロードし、アルバムに残ります。 – Vijay