xcode 无法在 iOS 上获得 Facebook publish_action 权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11319530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:46:26  来源:igfitidea点击:

Can't get the Facebook publish_action permission on iOS

iosxcodefacebookfacebook-graph-apifacebook-ios-sdk

提问by Darren

I've spent hours on this and can't get it to work. Basically I just want a button in my app that will 'Like' itself on Facebook. I've created the app on dev Facebook and have an associated App Page. In my code I request these permissions:

我已经在这上面花了几个小时,但无法让它发挥作用。基本上我只想在我的应用程序中有一个按钮,它会在 Facebook 上“喜欢”自己。我已经在开发 Facebook 上创建了该应用程序并有一个关联的应用程序页面。在我的代码中,我请求这些权限:

_permissions =  [NSArray arrayWithObjects:@"publish_stream", @"publish_actions", @"user_birthday", nil];

I can retrieve a profile picture fine, but when I try to 'Like' using this code:

我可以很好地检索个人资料图片,但是当我尝试使用此代码“喜欢”时:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       _facebook.accessToken, @"access_token",
                                       nil];
        [_facebook requestWithGraphPath:@"329756493773381/og.likes" andParams:params andHttpMethod:@"POST" andDelegate:self];

I get this error response:

我收到此错误响应:

(facebookErrDomain error 10000.)" UserInfo=0x20090590 {error={
    code = 200;
    message = "(#200) Requires extended permission: publish_actions";
    type = OAuthException;
}}

When logging in on the app, Facebook asks me for permission to see my birthday, and tell's me it will Post on my behalf but it seems to not get the publish_actions permission.

登录应用程序时,Facebook 要求我允许查看我的生日,并告诉我它将代表我发布,但它似乎没有获得 publish_actions 权限。

Is there something i'm missing that I need to do?

有什么我需要做的事情吗?

I see Temple Run has a Facebook Like button and offers bonus coins for pressing it. This is what I wish to achieve.

我看到 Temple Run 有一个 Facebook Like 按钮,按下它会提供奖励金币。这就是我希望实现的目标。

EDIT -------

编辑 - - - -

I've changed my permissions to just @"publish_actions", @"user_birthday" and now the auth dialogue says

我已将我的权限更改为仅@"publish_actions"、@​​"user_birthday",现在身份验证对话显示

"This app may post on your behalf, including objects you liked and more"

“此应用程序可能会代表您发布信息,包括您喜欢的物品等”

which seems to be the publish_actions permission, however I was still getting the error

这似乎是 publish_actions 权限,但是我仍然收到错误

message = "(#200) Requires extended permission: publish_actions";

message = "(#200) 需要扩展权限:publish_actions";

I've changed this line:

我改变了这一行:

[_facebook requestWithGraphPath:@"329756493773381/og.likes" andParams:params andHttpMethod:@"POST" andDelegate:selrf];

to this:

对此:

[_facebook requestWithGraphPath:@"329756493773381/og.likes" andDelegate:self];

and I do now get a response back, although it doesn't post a 'like'

我现在确实得到了回复,尽管它没有发布“喜欢”

This is the result response:

这是结果响应:

{
    data =     (
    );
    paging =     {
        next = "https://graph.facebook.com/329756493773381/og.likes?sdk=ios&sdk_version=2&access_token=BAAGeAp3ZBGwoBAPICjlgB5zK0YECyP8yElf8hJoMrx8Qs4vjeZAK5PlXFAVbGM1JyXHE0wZBvU0aBeCzCUTZBejQgoJ44CAIQsrG64TfrHdxjMqWD&format=json&offset=25&limit=25";
    };
}

Any idea what to try next?

知道接下来要尝试什么吗?

EDIT 2 --------------- I'm making progress with this. I've added the users id to the graph request like this

编辑 2 --------------- 我正在这方面取得进展。我已经将用户 ID 添加到这样的图形请求中

NSString *graphPath = [NSString stringWithFormat:@"%@/og.likes",facebookID];

and used these parameters

并使用这些参数

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       @"AAAGeAp3ZBGwoBABvKjsPZAoQQNG9cDPJI2v2TI8acyyPSNtm9ZBkfydHqVZAjSKWSbLuvFwxyxSrCts7kFZCnh7Y6f5PFNlWb6smF8XF33wlRZBgfLyhT1", @"access_token",
                                       @"http://samples.ogp.me/329756493773381", @"object",
                                       nil];

and now I get a like showing up on my timeline :-) I was using the access-token supplied by the Facebook login, but it seems the one supplied by the graph object is different.

现在我在我的时间线上得到了一个赞 :-) 我使用的是 Facebook 登录提供的访问令牌,但似乎图形对象提供的那个是不同的。

Now, the like that i'm seeing has this pattern:

现在,我看到的就是这种模式:

Darren likes object on MyAPP

Darren 喜欢 MyAPP 上的对象

Is it even possible to have it as

甚至有可能将它作为

Darren likes MyAPP with it linking to the app Facebook page?

Darren 喜欢 MyAPP,因为它链接到应用程序 Facebook 页面?

Thanks

谢谢

采纳答案by Alexander of Norway

Check if you have done the steps below:

检查您是否已完成以下步骤:

https://developers.facebook.com/docs/opengraph/tutorial/

https://developers.facebook.com/docs/opengraph/tutorial/

"Note: The user-prompt for this permission will be displayed in the first screen of the Enhanced Auth Dialog and cannot be revoked as part of the authentication flow." - link

“注意:此权限的用户提示将显示在增强身份验证对话框的第一个屏幕中,并且不能作为身份验证流程的一部分撤销。” - 关联

Try this if you havent already:

如果你还没有试试这个:

Auth Dialog -> Configure how Facebook refers users to your app - > Add publish_actions permissions.

身份验证对话框 -> 配置 Facebook 如何将用户引荐到您的应用程序 -> 添加 publish_actions 权限。

https://developers.facebook.com/docs/opengraph/authentication/

https://developers.facebook.com/docs/opengraph/authentication/

"To enable the new Auth Dialog, go to the App Dashboard, and enable the Enhanced Auth Dialog setting in the Advanced section of your app." -link

“要启用新的身份验证对话框,请转到应用仪表板,并在应用的高级部分启用增强身份验证对话框设置。” -关联

Hope this helps!

希望这可以帮助!

回答by Joakim Engstrom

This seems to be the same problem I was having on this SO question: Facebook iOS SDK 3.0, implement like action on a url?

这似乎与我在这个 SO 问题遇到的问题相同: Facebook iOS SDK 3.0,在 url 上实现类似操作?

But if you want to like you facebook page in the app, there is no way to do that in Objective C. Only with the javascript Like button which you can generate here: https://developers.facebook.com/docs/reference/plugins/like/

但是,如果您想在应用程序中为您的 Facebook 页面点赞,则在 Objective C 中无法做到这一点。只能使用您可以在此处生成的 javascript Like 按钮:https: //developers.facebook.com/docs/reference/插件/喜欢/

The way Temple Run does it is to display the Like button in a web-view, so their like button is actually on their server, this is perhaps an ugly-hack but will work for liking a page.

Temple Run 的做法是在 Web 视图中显示“赞”按钮,因此他们的“赞”按钮实际上位于他们的服务器上,这可能是一个丑陋的技巧,但可以用于赞页面。