gpt4 book ai didi

iphone - 如何在 iPhone 中以编程方式使用 fbrequest 在 Facebook 好友墙上发帖?

转载 作者:行者123 更新时间:2023-11-29 03:58:40 26 4
gpt4 key购买 nike

我搜索了每个地方,但没有得到如何做到这一点的单个提示......我也得到了一些代码,但它不起作用......任何人都可以建议我任何教程或示例代码来做到这一点!提前致谢我正在尝试以下代码::

-(void)inviteFriend:(CustomButton *)sender
{

NSString *str=[NSString stringWithFormat:@"%@/feed",sender.inviteUserId];
if (FBSession.activeSession.isOpen)
{
//UIImage *image = [UIImage imageNamed:@"testImage.png"];

hudApp = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hudApp.labelText = @"Page Sharing...";
[self performSelector:@selector(timeout:) withObject:nil afterDelay:60*5];

// NSString *fbMessage = [NSString stringWithFormat:@"test"];
NSString *fbMessage = @"hello testing";


NSMutableDictionary* params=[NSDictionary dictionaryWithObjectsAndKeys:fbMessage, @"message", FBSession.activeSession.accessToken, @"access_token", nil];

NSLog(@"feed::%@",str);

[FBRequestConnection startWithGraphPath:str
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result,NSError *error) {
NSLog(@"result::%@",result);


if(error)
{
NSLog(@"fail : %@",error.localizedDescription);
hudApp.labelText = [NSString stringWithFormat:@"%@",error.localizedDescription];
}
else
{
NSLog(@"Success facebook post");
hudApp.labelText = [NSString stringWithFormat:@"Success"];
// txtView.text = @"success";
NSLog(@"success");
}

hudApp.mode = MBProgressHUDModeCustomView;
[self performSelector:@selector(dismissHUD:) withObject:nil afterDelay:1.0];
}];
}
else
{
NSArray *permissions = [NSArray arrayWithObject:@"publish_stream"];
[FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state,NSError *error) {
NSLog(@"session.permissions ? : %@", session.permissions);
[self sessionDoneForPageShare:session state:state error:error withuserid:str];
}
];
}


}


-(void)sessionDoneForPageShare:(FBSession *)session state:(FBSessionState)state error:(NSError *)error withuserid :(NSString *)usreid
{
//UIImage *image = [UIImage imageNamed:@"testImage.png"];

NSLog(@"feed::%@",usreid);
hudApp = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hudApp.labelText = @"Page Sharing...";
[self performSelector:@selector(timeout:) withObject:nil afterDelay:60*5];

//NSString *fbMessage = [NSString stringWithFormat:@"test"];
NSString *fbMessage = @"hello testing";

NSLog(@"State : %d **** Facebook Message : %@",state,fbMessage);

// NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys: fbMessage, @"message", nil];

NSMutableDictionary* params=[NSDictionary dictionaryWithObjectsAndKeys:fbMessage, @"message", FBSession.activeSession.accessToken, @"access_token", nil];

[FBRequestConnection startWithGraphPath:usreid
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

if(error)
{
NSLog(@"fail : %@",error.localizedDescription);
// txtView.text = [NSString stringWithFormat:@"%@",error.localizedDescription];
NSLog(@"%@",[NSString stringWithFormat:@"%@",error.localizedDescription]);
hudApp.labelText = [NSString stringWithFormat:@"%@",error.localizedDescription];
}
else
{
NSLog(@"Success facebook post");
hudApp.labelText = [NSString stringWithFormat:@"Success"];
//txtView.text = @"success";
NSLog(@"success");
}

hudApp.mode = MBProgressHUDModeCustomView;
[self performSelector:@selector(dismissHUD:) withObject:nil afterDelay:1.0];
}];
}

最佳答案

要向 friend 的留言墙上发帖,您需要向 /{friend_id}/feed 发出请求。然而,Facebook有disabled posting to friends' wall since February 6, 2013 :

Removing ability to post to friends walls via Graph API

We will remove the ability to post to a user's friends' walls via the GraphAPI. Specifically, posts against [user_id]/feed where [user_id] isdifferent from the session user, or stream.publish calls where thetarget_id user is different from the session user, will fail. If youwant to allow people to post to their friends' timelines, invoke thefeed dialog. Stories that include friends via user mentions tagging oraction tagging will show up on the friend’s timeline (assuming thefriend approves the tag). For more info, see this blog post.

关于iphone - 如何在 iPhone 中以编程方式使用 fbrequest 在 Facebook 好友墙上发帖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16167314/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com