2011-01-31 157 views
1

這裏是我使用,以上傳照片到我的粉絲專頁我的代碼的關鍵點上傳照片到Facebook粉絲頁面

_permissions = [[NSArray arrayWithObjects:@"read_stream", @"offline_access", @"publish_stream", @"manage_pages", @"user_photos", @"friends_photos",nil] retain]; 

[_facebook requestWithGraphPath:@"/me/accounts" andDelegate:self]; 

我分析,從結果ACCESS_TOKEN頁面,並用它來冒充下一頁請求,我可以successifuly從結果分析出網頁主人的信息,所以我想我是的access_token OK

- (IBAction)getUserInfo:(id)sender { 
      _facebook.accessToken = self.pageAccessToken; 
      [_facebook requestWithGraphPath:@"me" andDelegate:self]; 
     } 

但如果我嘗試上傳照片到我的網頁相冊這樣的:

- (IBAction)uploadPhoto:(id)sender { 

      NSString *path = @"http://dl.dropbox.com/u/xxxxxxx/Icon.png"; 
      NSURL *url = [NSURL URLWithString:path]; 
      NSData *data = [NSData dataWithContentsOfURL:url]; 
      UIImage *img = [[UIImage alloc] initWithData:data]; 

      NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
             img, @"picture", 
             nil]; 



      _facebook.accessToken = self.pageAccessToken; 


      [_facebook requestWithMethodName:@"photos.upload" 
           andParams:params 
          andHttpMethod:@"POST" 
           andDelegate:self]; 

      //or like 
      // [_facebook requestWithGraphPath:@"/me/photos" ... 
      // [_facebook requestWithGraphPath:@"/<PAGE_ID>/photos" ... 
      // [_facebook requestWithGraphPath:@"/<ALBUM_ID>/photos" ... 

      [img release]; 
     } 

我總是得到錯誤:

Error Domain=facebookErrDomain Code=190 "The operation couldn’t be completed. (facebookErrDomain error 190.)" UserInfo=0x15fca0 {request_args=(
{ 
key = method; 
value = "photos.upload"; 
}, 
{ 
key = sdk; 
value = ios; 
}, 
{ 
key = "sdk_version"; 
value = 2; 
}, 
{ 
key = "access_token"; 
value = "1939755xx612731|8ceab6c65ce0194d079f41ef-1068726246|3x2697618282|xdSRakxsdjezx9N1dnr9cRe6ICk"; 
}, 
{ 
key = format; 
value = json; 
} 
), error_msg=Invalid OAuth 2.0 Access Token, error_code=190} 

} 

(注:我稍微修改ACCESS_TOKEN只是爲了保護)

+0

這可能是在Facebook的權限問題?您是否有權發佈/上傳照片? – blueberryfields 2011-01-31 07:49:56

回答