2013-03-14 72 views
1

我將照片上傳爲開放圖形對象,然後將其綁定到我的開放圖形動作中,一旦它返回URL。Facebook FBOpenGraphAction用戶消息不起作用

目前爲止一切正常,但我無法獲得自定義用戶消息「TEST TEST TEST TEST!」現身。我一直在從各個角度觸及這個問題,似乎無法得到確定。有任何想法嗎?

enter image description here

- (void)postPhotoThenOpenGraphAction { 

     FBRequestConnection *connection = [[FBRequestConnection alloc] init]; 

     // First request uploads the photo. 
     FBRequest *request1 = [FBRequest requestForUploadPhoto:[UIImage imageWithData:[NSData dataWithContentsOfFile:picture.pathSmall]]]; 

     [connection addRequest:request1 completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 

      if (!error) { 
      } else { 
       [self showFacebookFailedError]; 
      } 
     } 
       batchEntryName:@"photopost"]; 


     // Second request retrieves photo information for just-created 
     // photo so we can grab its source. 
     FBRequest *request2 = [FBRequest requestForGraphPath:@"{result=photopost:$.id}"]; 

     [connection addRequest:request2 completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 

      if (!error && result) { 

       NSString *source = [result objectForKey:@"source"]; 
       [self postOpenGraphActionWithPhotoURL:source]; 

      } else { 
       [self showFacebookFailedError]; 
      } 
     } 
     ]; 

     [connection start]; 


     } 

    - (void)postOpenGraphActionWithPhotoURL:(NSString*)photoURL { 

     id<PTOGPicture> photoGraphObject = [self pictureObjectForPicture:self.picture]; 
     id<PTOGSharePicture> action = (id<PTOGSharePicture>)[FBGraphObject graphObject]; 

     action.photo = photoGraphObject; 

     if (self.selectedPlace) { 
      action.place = self.selectedPlace; 
     } 
     if (self.selectedFriends.count > 0) { 
      action.tags = self.selectedFriends; 
     } 

     action.message = @"TEST TEST TEST TEST!"; 

     if (photoURL) { 

      NSMutableDictionary *image = [[NSMutableDictionary alloc] init]; 

      [image setObject:photoURL forKey:@"url"]; 

      NSMutableArray *images = [[NSMutableArray alloc] init]; 
      [images addObject:image]; 

      action.image = images; 
     } 

     // Create the request and post the action to the. 
     [FBRequestConnection startForPostWithGraphPath:@"me/myappapp:share" 
              graphObject:action 
            completionHandler:^(FBRequestConnection *connection, 
                 id result, 
                 NSError *error) { 
      //... code taken out for brevity 

     }]; 
     } 
+0

您是否設法解決此問題?自定義消息也不適用於我。 – vburojevic 2014-06-30 08:37:21

回答

0

我有一個是你想要的東西的工作原理簡單的版本:

首先創建你的操作對象,如你所願:

- (void)shareOnFacebook { 
    NSMutableDictionary<FBGraphObject> *action = [FBGraphObject graphObject]; 
    action[@"<OPEN_GRAPH_OBJ>"] = obj; 
    action[@"image[0][url]"] = url; 
    action[@"image[0][user_generated]"] = @"true"; 
    action[@"message"] = @"some message here"; 

    [FBRequestConnection startForPostWithGraphPath:@"me/<app_namespace>:<action>" graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
    }]; 
} 

但是,對於要求這個工作,是你必須在動作設置頁面上設置這兩個權限:

enter image description here

我希望它有幫助。