アプリをFacebookと相互作用させようとしています。私は彼らのFacebookiOSSDK(3.0)とXcode4.2を使用しています。これまでのところ、アプリの適切な権限も要求するログインメソッドを実装しました。このメソッドは、ビューコントローラーからボタンをクリックすると呼び出されます。このメソッドはアプリデリゲートにあります。ログイン後に私が欲しいのは、ユーザーの壁に写真を投稿することです。このボタンが配置されているビューコントローラはフォトビューアであるため、手元に画像があります。壁に画像を投稿するために私が見たすべてのメソッドには、アプリデリゲートにFacebookタイプのオブジェクトがあることが含まれるという私の問題があります。これを可能にするには、非推奨のFacebook.hをインポートし、インポートできるように手動でプロジェクトに追加する必要があります。これにより、多くのエラーが発生します。では、どうすればこれを行うことができますか?非推奨のヘッダーを使用してこのFacebookオブジェクトをどのように宣言しますか?または、新しいSDKのFacebookオブジェクトなしでそれを行うことができますか?
Ok。だから私はこれで部分的にそれを解決しました:
- (void)facebookButtonHit:(id)sender{
DrillDownAppAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate openSessionWithAllowLoginUI:YES];
if(FBSessionStateOpen){ NSString *linkul=@"";
NSString *captt=@"";
//seteaza link-ul postului
if([self.optiune isEqualToString:@"SETURI TEMATICE"]){
linkul=@"http://www.calinevents.com/seturi.html";}
captt=@"SET TEMATIC CALIN EVENTS MODEL ";
NSInteger i=_pageIndex+1;
NSString *mno=[NSString stringWithFormat:@"%i",i];
captt= [captt stringByAppendingString:mno];
//seteaza parametrii postului
NSString *Path1 = [[NSBundle mainBundle] bundlePath];
NSString *Datele1 = [Path1 stringByAppendingPathComponent:@"Seturi.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:Datele1];
NSDictionary *tempdicty=[[tempDict objectForKey:@"Rows"] objectAtIndex:_pageIndex];
NSString *tempurl=[tempdicty objectForKey:@"URL"];
NSMutableDictionary *postParams = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
linkul, @"link",
tempurl, @"picture",
@"Imi place acest produs Calin Events", @"name",
captt, @"caption",
@" ",@"description",
nil];
//posteaza pe Facebook
UIAlertView *incarcare=[[UIAlertView alloc] initWithTitle:@""
message:@"Se publica imaginea...\nVa rugam asteptati"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
[incarcare setBackgroundColor:[UIColor blackColor]];
[incarcare show];
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:postParams
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSString *alertText;
if (error) {
alertText = [NSString stringWithFormat:
@"S-a produs o eroare!\n Va rugam incercati din nou.",
error.domain, error.code];
} else {
alertText = [NSString stringWithFormat:
@"Imaginea a fost postata cu succes!\n Va multumim!",
[result objectForKey:@"id"]];
}
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:@""
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
[incarcare dismissWithClickedButtonIndex:0 animated:YES];
}];
}
}
しかし今、私は次のエラーを受け取ります。このアクションが最初に呼び出されると、エラーコード= 5、HTTPステータスコード=400になります。次にボタンを押すと、ボタンが機能し、画像がすべての情報とともに正しく投稿されます。次にボタンを押すと、次にエラーが出力され、次に正しく公開されます。そして、それはエラー、公開、エラー、公開などになります。これを解決するにはどうすればよいですか?