Facebook Graph API /me/feed 返回 302 响应
我正在尝试让 FB.api /me/feed 正常工作,但它返回 302 Found 状态。
当用户不允许“stream_publish”扩展权限时,该函数将按预期工作,并返回错误,表明用户没有为此操作授予权限。
然而,在接受扩展权限并再次进行相同的调用后,我收到来自 Facebook 的 302 Found 响应,并弹出 JS 错误。
JS 错误:语法错误 - < !DOCTYPE html>
检查网络响应我看到正在进行的调用:
https://graph.facebook.com/me/feed?access_token=[access_token]&callback=FB.ApiServer._callbacks.f32a1cd2d00c92&message=Reading%20JS%20SDK% 20documentation&method=post&pretty=0&sdk=joey
以及返回的状态: 302 Found
响应不应该是 200 OK 吗?我在这里做错了什么?下面是与问题相关的代码...提前非常感谢!
PS 提到其他 FB.api 调用(例如 /me 和 /me/permissions)工作得很好可能会有所帮助。只有 FB.api /me/feed 似乎正在重新调整 302 Found。
<body>
<a href="#" onclick="nowPost()">nowPost</a>
<script>
function nowPost() {
var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
}
</script>
</body>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : fbAppId,
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true
});
(function()
{
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/<c:out value="${locale}" />/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
更新:我注意到其他使用 FB.api /user_id/feed/ 的 Facebook 应用程序也遇到了同样的问题。除非这以某种方式连接到 oAuth 2.0(我确实将我们的 JS SDK 升级到了),否则我倾向于认为 Facebook 再次破坏了某些东西。
I'm trying to get FB.api /me/feed working, but it is returning a 302 Found status.
When a user has not allowed 'stream_publish' Extended Permissions the function works as intended, returning an error that the user has not authorized permissions for this action.
However, after accepting the Extended Permissions, and making the same call again, I get a 302 Found response from Facebook and a JS error pops up.
JS Error: syntax error - < !DOCTYPE html> <html lang="en" id="facebook" class="no_js">
checking the NET response I see the call being made:
https://graph.facebook.com/me/feed?access_token=[access_token]&callback=FB.ApiServer._callbacks.f32a1cd2d00c92&message=Reading%20JS%20SDK%20documentation&method=post&pretty=0&sdk=joey
and the returned status: 302 Found
Shouldn't the response be a 200 OK? What am I doing wrong here? Below is the code relevant to the problem... thanks a ton in advance!
P.S. It might be helpful to mention that OTHER FB.api calls such as /me and /me/permissions work just fine. Only FB.api /me/feed seems to be retuning a 302 Found.
<body>
<a href="#" onclick="nowPost()">nowPost</a>
<script>
function nowPost() {
var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
}
</script>
</body>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : fbAppId,
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true
});
(function()
{
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/<c:out value="${locale}" />/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
Update: I noticed that other facebook apps using FB.api /user_id/feed/ were getting the same problem. Unless this is somehow connected to oAuth 2.0 (which I did upgrade our JS SDK to) I am inclined to think Facebook has broken something again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论