Facebook需要扩展许可:publish_actions [英] Facebook Requires extended permission: publish_actions
问题描述
我正在开发一个比赛和促销相关的Facebook应用程序,我的目的是在我公司的页面上创建一个可以访问应用程序的标签。
I'm in the process of developing a Contest and Promotion-related Facebook app and my intent is to to create a tab on my company's page that will provide access to the app.
一旦他们的用户可以提名本地公司获得奖励。稍后的;一旦提名进入,用户可以投票获胜。
Once their, users can nominate local companies for awards. Later on; once the nominations are in, users can vote for a winner.
我将Open Graph集成到我的应用程序中,以便我可以利用对象类型(组织
),动作类型(提名
,投票
)和聚合(提名
)。我的主要目标是将这些操作转移到用户的时间表上。
I've integrated Open Graph into my app so that I can take advantage of Object Types (Organization
), Action Types (Nominate
, Vote For
), and Aggregations (Nominations
). My main objective is to then transfer these actions onto the user's timeline.
我已经使用了食谱箱示例作为我的基础。我提供了我的代码来演示验证和提交操作类型/对象类型组合所需的后期操作。
I've used the recipebox example as my base. I've provided my code to demonstrate authentication and the post action required to submit an action type/object type combination.
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head prefix="og: http://ogp.me/ns# og_<<app namespace>>: http://ogp.me/ns/apps/<<app namespace>>#">
<meta property="fb:app_id" content="<<app id>>" />
<meta property="og:type" content="<<app namespace>>:organization" />
<meta property="og:title" content="Client 1" />
<meta property="og:image" content="<<client image path>>" />
<meta property="og:description" content="Client 1 description here ... " />
<meta property="og:url" content="<<custom client URL>>">
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
// Init the SDK upon load
window.fbAsyncInit = function() {
FB.init({
appId : '<<app id>>', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// listen for and handle auth.statusChange events
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.authResponse) {
// user has auth'd your app and is logged into Facebook
FB.api('/me', function(me){
if (me.name) {
document.getElementById('auth-displayname').innerHTML = me.name;
}
})
document.getElementById('auth-loggedout').style.display = 'none';
document.getElementById('auth-loggedin').style.display = 'block';
} else {
// user has not auth'd your app, or is not logged into Facebook
document.getElementById('auth-loggedout').style.display = 'block';
document.getElementById('auth-loggedin').style.display = 'none';
}
});
// respond to clicks on the login and logout links
document.getElementById('auth-loginlink').addEventListener('click', function(){
FB.login();
});
document.getElementById('auth-logoutlink').addEventListener('click', function(){
FB.logout();
});
}
function nominate () {
FB.api('/me/<<app namespace>>:Nominate&organization=<<custom client URL>>', 'post', function(response) {
if (! response || response.error) {
alert('Error occured');
console.log(response);
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<div id="auth-status">
<div id="auth-loggedout">
<a href="#" id="auth-loginlink">Login</a>
</div>
<div id="auth-loggedin" style="display:none">
Hi, <span id="auth-displayname"></span>
(<a href="#" id="auth-logoutlink">logout</a>)
</div>
</div>
<h2>Client 1</h2>
<form>
<input type="button" value="Nominate" onclick="nominate()" />
</form>
<fb:activity actions="<<app namespace>>:nominate"></fb:activity>
</body>
</html>
测试用户遇到以下错误:
A test user is encountering the following error:
Requires extended permission: publish_actions
而且我遇到以下错误(我是这个应用程序的管理员):
And I am encountering the following error (I am an Admin for this app):
This method must be called with an app access_token
第一个错误对我来说是令人不安的。我不能从 Apps |中选择
。另外,我已经提出的补救措施表明,我将应用程序重新分类到 publish_actions
< My App> |权限|扩展权限游戏
(这不起作用),并完成我的汇总(我没有;仍然不工作)。
The first error is troubling to me. I cannot select publish_actions
from Apps | <My App> | Permissions | Extended Permissions
. Also, remedies I've encounted suggest I re-categorize my app to Games
(this does not work) and to complete my Aggregations (I did; still does not work).
- 如何克服这个错误?
- 我可以如何修复我的
必须使用app access_token
错误来调用此方法?
- How can I overcome this error?
- What can I do to fix my
This method must be called with an app access_token
error?
提前感谢
Mike
编辑
我相信我遇到的 access_token
错误是由于我正在使用页面选项卡URL直接测试/与应用程序进行交互;不通过Facebook。
I believe the access_token
error I was encountering was due to the fact that I was testing/interacting with the app directly on the Page Tab URL; not through Facebook.
我不再收到需要扩展权限:publish_actions错误
;但是,我的测试人员和开发人员都是。我知道我遇到这个错误,因为在初始的facebook.com登录提示下没有请求publish_actions权限。
I am no longer receiving the Requires extended permission: publish_actions error
; however, my testers and developers are. I know that I am encountering this error because the publish_actions permission is not requested at the initial facebook.com login prompt.
如果我的开发人员/测试人员注销Facebook,然后记录回到我的提示:
If my Developers/Testers logout of Facebook, then log back in with my prompt:
FB.login(function (response) { }, { scope:'publish_actions'});
然后这个权限和应用被集成到他们的Facebook会话中。
Then this permission and app is integrated into their Facebook session.
我的最后一个问题是 - 在没有登录/退出Facebook的情况下,是否有一个偏好的方法来请求此权限?
My final question is- is there a defacto, preferred method to request this permission without logging in/out of Facebook?
推荐答案
我已经修复了我的两个错误。感谢那些向我提供反馈的人,并把我放在正确的道路上。
I have fixed both of my errors. Thank you to those who provided me with feedback and put me on the right path.
这些错误已经解决了:
1. Requires extended permission: publish_actions
2. This method must be called with an app access_token
对于初学者来说,CBroe是对的。因为我需要扩展权限(publish_actions)
我需要指定这是在 FB.login()$ c中的回调函数之后的我的选项对象$ c> like so:
For starters, CBroe is right. Since I require extended permissions (publish_actions)
I need to specify this is my options object after the callback function in FB.login()
like so:
FB.login(function (response) {
if (response.authResponse) { // The user has authenticated
authenticatedSoDoSomething();
}
else { // The user has not authenticated
notAuthenticatedSoDoSomethingElse();
}
}, { scope:'publish_actions' });
最后,我没有使用JavaScript SDK将操作发布到用户的时间轴,通过 FB.api()
。这是代码 使用:
Lastly, I had no success using the JavaScript SDK to publish an action to a user's timeline via FB.api()
. This is the code I was using:
FB.api('/me/<<app namespace>>:<<my action>>&<<my object>>=<<a URL>>', 'post',
function(response) {
if (! response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
})
我忽略了包含应用访问令牌。应用程序访问令牌可以通过连接应用程序ID,后跟管道,然后连接应用程序密码来构建。
I neglected to include the app access token. The app access token can be constructed by concatenating the app id, followed by a pipe, followed by the app secret.
我使用PHP SDK来完成此请求,因为我想要保持我的api秘密秘密。以下是我使用的[大部分]代码:
I used the PHP SDK to fulfill this request as I wanted to keep my api secret a secret. Here is [most] of the code I used:
require_once('facebook-php-sdk/src/facebook.php');
$facebook = new Facebook(
array(
'appId' => '<<my app id>>',
'secret' => '<<my app secret>>'));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
}
catch (FacebookApiException $e) {
error_log($e);
$user = null;
echo json_encode(array('success' => false));
}
}
try {
$facebook->api('/' . $user . '/<<app namespace>>:<<my action>>&<<my object>>=<<a URL>>', 'POST', array('access_token' => $facebook->getAppId() . '|' . $facebook->getApiSecret()));
}
catch (FacebookApiException $e) {
echo var_dump($e->getResult());
}
希望这有帮助!
这篇关于Facebook需要扩展许可:publish_actions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!