0

Facebook 内容在墙和主页上看起来不同,使用 iOS 的 facebook sdk 从 iOS 应用发布内容后,

使用的代码:我们使用以下代码在 facebook 墙上发布数据。

[NSMutableDictionary dictionaryWithObjectsAndKeys:
         @"Found this app ", @"message",
         @"AppName", @"name",
       @"App Title", @"caption",
         @"Description data", @"description",
        @"Link URL", @"link",
         @"Image URL", @"picture",nil];
 // create the connection object.
        FBRequestConnection *newConnection = [[[FBRequestConnection alloc] initWithTimeout:kRequestTimeoutInterval] autorelease];

        // create the request object, using the fbid as the graph path as an alternative the request* static methods of the
        // FBRequest class could be used to fetch common requests, such as /me and /me/friends
        FBRequest *request=[[[FBRequest alloc] initWithSession:activeSession
                                                     graphPath:@"me/feed"
                                                    parameters:params
                                                    HTTPMethod:@"POST"] autorelease];

详细信息:当我们要发布此数据并且链接 url 可用时,主屏幕和个人资料屏幕中的内容看起来会有所不同。

相反,应用程序名称在主页中显示链接 URL 标题,但在个人资料页面中显示正确的内容,如应用程序标题。它只会从 iOS 应用发布,从 Android 应用看起来不错。

请帮助我 tikamchandrakar@gmail.com 或 tikam.chandrakar@xymob.com 让我知道是否有任何不清楚的地方。谢谢

4

1 回答 1

2

试试这个代码。它对我来说很完美-

// Helper method to request publish permissions and post.
- (void)requestPermissionAndPost {

[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
                                      defaultAudience:FBSessionDefaultAudienceFriends
                                    completionHandler:^(FBSession *session, NSError *error) {
                                        if (!error && [FBSession.activeSession.permissions indexOfObject:@"publish_actions"] != NSNotFound) {

                                            // Now have the permission
                                            [self postOpenGraphAction];
                                        } else if (error){
                                            // Facebook SDK * error handling *
                                            // if the operation is not user cancelled
                                            if (error.fberrorCategory != FBErrorCategoryUserCancelled) {
//                                                    [self presentAlertForError:error];
                                            }
                                        }
                                    }];
}

// Creates the Open Graph Action.
- (void)postOpenGraphAction {


NSString *pageId = @"";

if ([pageIdArray count] > 0) {
    pageId = [[pageIdArray objectAtIndex:0] objectForKey:@"page_id"];
}else{
    pageId = @"";
}

//http://mistoh.com/mistohws/CategoriesIcon/CategoryIcon_%1$s.png

[FBRequestConnection startWithGraphPath:@"me/feed"
                             parameters:@{
                                          @"link":@"http://mistoh.com/mistohws/CategoriesIcon/CategoryIcon_1.png",
                                          @"message":[NSString stringWithFormat:@"I just shared a Mistoh at %@",self.mistohNameStr],
                                          @"place":[NSString stringWithFormat:@"%@",pageId],
                                          @"name":[NSString stringWithFormat:@"%@",self.mistohNameStr],
                                          @"description":[NSString stringWithFormat:@"%@",self.mistohDescStr],
                                          @"address":[NSString stringWithFormat:@"%@",self.mistohAddressStr],
                                          @"tags":[NSString stringWithFormat:@"%@",self.selectedFriendsStr]
                                          }
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                          //verify result

                          if (!error) {

                              [[[UIAlertView alloc] initWithTitle:@"Shared Mistoh Successfully!!"
                                                          message:@""
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles:nil]
                               show];

                          }else{
                              [[[UIAlertView alloc] initWithTitle:@"Error"
                                                          message:@"Error while sharing mistoh with friends."
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles:nil]
                               show];

                              NSLog(@"Error : %@",[error description]);
                          }

                      }];

}

它在 Facebook 墙上和时间轴上看起来不错。谢谢你..

于 2013-11-14T07:23:59.733 回答