2013-04-28 20 views
0
批調用的一部分

我嘗試使用批處理請求後做出比FB裏一張照片,但我不斷收到來自Fb的服務器超時錯誤......上傳多個二進制信息作爲在iOS

這是我的代碼..

UIImage * imgFile1 = [UIImage imageNamed:@「iTGps.png」]; NSData * imageData = UIImageJPEGRepresentation(imgFile1,0.5);

NSString *jsP1 = [NSString stringWithFormat:@"{ \"method\": \"POST\", \"relative_url\": \"me/photos\",\"body\":\"message=My cat photo\",\"attached_files\":\"%@\"}",imageData]; 

NSString *jsonRequestsArray = [NSString stringWithFormat:@"[%@,%@,%@]",jsP1,jsP1,jsP1]; 
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:jsonRequestsArray forKey:@"batch"]; 

FBRequestConnection *connect = [[FBRequestConnection alloc] initWithTimeout:60]; 

// do Fb request 
FBRequest *request = [FBRequest requestWithGraphPath:@"me/photos" 
             parameters:params 
             HTTPMethod:@"POST"]; 

// add connection 
[connect addRequest:request 
    completionHandler:^(FBRequestConnection *connection, 
        id result, 
         NSError *error) { 

     NSLog(@"Result:%@,%@",result,error); 

    }]; 

[connect start]; 

我在哪裏做錯了?

錯誤代碼是很長的,所以我切割的中間部分(我想是二進制圖像)

2013年4月28日20:03:32.435 trueGps [1887:1a603]結果:(空),錯誤Domain = com.facebook.sdk Code = 5「操作無法完成(com.facebook.sdk錯誤5)」UserInfo = 0x14454010 {com.facebook.sdk:ErrorInnerErrorKey =錯誤域= NSURLErrorDomain代碼= -1001 「請求超時。」的UserInfo = 0x14492d40 {NSErrorFailingURLStringKey = https://graph.facebook.com/me/photos?sdk=ios&batch=%5B%7B%20%22method%22%3A%20%22POST%22%2C%20%22relative_url%22%3A%20%22me%2Fphotos%22%2C%22body%22%3A%22message%3DMy%20cat%20photo%22%2C%22attached_files ....

NSLocalizedDescription =請求超時,NSUnderlyingError = 0x2a90f620 「請求超時。」},com.facebook.sdk:HTTPStatusCode = 200}

回答

0

我解決問題..但仍然有更多的帖子,每個人只有一張照片..

NSString * rel_url = [NSString stringWithFormat:@「%@/photos」,nomeAlbum]; NSString * jsP1 = [NSString stringWithFormat:@「{\」method \「:\」POST \「,\」relative_url \「:\」%@ \「,\」body \「:\」message = My_cat_photo \「,\」attached_files \「:\」file1 \「}」,rel_url]; NSString * jsonRequestsArray = [NSString stringWithFormat:@「[%@]」,jsP1];}};}}

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:jsonRequestsArray forKey:@"batch"]; 

[params setObject:imgFile1 forKey:@"file1"]; 

[FBRequestConnection startWithGraphPath:rel_url 
          parameters:postParams 
          HTTPMethod:@"POST" 
          completionHandler:^(FBRequestConnection *connection, 
               id result, 
               NSError *error) { 
          }];