【问题标题】:What is the error in the following code以下代码中的错误是什么
【发布时间】:2015-04-13 05:47:13
【问题描述】:

这是一个函数,当用户单击按钮参加 Facebook 上的活动时调用,以下代码从用户那里获取登录信息,并将特定活动添加到用户 fb 活动中以参加活动。

这些代码给了我语法错误,我不知道是什么错误。请帮助其有需要的人。

function gogingtoevent() {
        FB.login(function(response) {
            if (response.status == 'connected') {
                FB.api('/816891388384961/attending', 
                 function (response) {
                   if (response && !response.error) {
                        alert('Attending');
                       }else{
                            alert (JSON.stringify(response));   
                       }
                    });
            }else{
                alert('Not Responding');
            }
        });
    }

【问题讨论】:

  • 实际的错误信息和错误的行号是什么?这段代码看起来语法正确(但格式可以更好)。
  • {"error":{"message":"不支持的get请求。请阅读developers.facebook.com/docs/…}}的Graph API文档
  • 这是一个生成的错误,我读取了错误代码,因为语法给出了错误
  • 您提供的 URL 似乎存在问题。您确定您的权限设置正确吗?这可能会有所帮助:stackoverflow.com/questions/20957095/…
  • 我将活动隐私设置为开放邀请

标签: facebook events syntax


【解决方案1】:

您需要对此边缘进行 POST 请求,并且您需要 rsvp_event 权限。

这一切都在文档中:

【讨论】:

  • 如何设置rsvp_event权限
  • 您需要在应用登录流程中请求它。 developers.facebook.com/docs/facebook-login/permissions/…
  • 我添加了 post 类型和 rsvp_event 权限范围:'read_stream,publish_stream,offline_access,rsvp_event'
  • read_stream,publish_stream,offline_access 都已弃用。你的代码现在看起来怎么样?没有代码,没有人可以帮助您。见developers.facebook.com/docs/javascript/reference/FB.api
  • FB.login(function(response) { if (response.authResponse) { FB.api("/816891388384961/attending", "POST", function (response) { if (response && !response .error) { alert('Attending'); }else{ alert (JSON.stringify(response)); } }); } },{ scope: 'rsvp_event' });
猜你喜欢
  • 1970-01-01
  • 2012-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-25
相关资源
最近更新 更多