向“/ me”发送请求2.0应用生成的请求 [英] Sending Request 2.0 app-generated request to other than "/me"

查看:111
本文介绍了向“/ me”发送请求2.0应用生成的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JS SDK或图形API发送应用程序生成的请求,但我不是成功和绝望的。问题是,当我向当前登录的用户发送请求时,一切都可以,但是当我尝试发送给不同的用户(即使这个用户已经授权我的应用程序)我收到OAuth异常#2用户无法发送此请求:未知错误,有时发送任何应用程序请求失败。

I am trying to send app-generated request using either JS SDK or graph API but I am not successful and desperate. Issue is that when I am sending request to currently logged user, everything is ok, but when I try to send to different user (even this user already authorized my app) I receive OAuth exception "#2 User can't send this request: Unknown error", sometimes "Failed to send any app requests".

我的应用程序启用了Request 2.0,并且已被授权使用publish_stream,read_stream和user_about_me权限。我所描述的同样的错误消息甚至在Graph API资源管理器中显示。

My app has Request 2.0 enabled and is authorized with publish_stream, read_stream and user_about_me permissions. Same error messages I described are shown even in Graph API explorer.

这里使用JS SDK描述完全相同的问题:
使用JavaScript SDK发送应用程序生成的请求

Exactly same issue is described here using JS SDK: Sending an App Generated Request with the JavaScript SDK

...这里使用Graph API:
发布应用程序生成的应用程序给Java的其他Facebook用户

... and here using Graph API: Posting app generated apprequest to other facebook users in Java

请帮助。

推荐答案

如果您想向用户发送请求,您应该使用App Access Token(https:/ /developers.facebook.com/docs/authentication/#applogin)。此电话是设计为执行服务器端,因为您不想共享您的应用访问令牌:

If you want send a request to a user, you should POST to the Graph API '/user_id/apprequests' using an App Access Token (https://developers.facebook.com/docs/authentication/#applogin). This call is to design to be executed server-side as you don't want to share your App Access Token:

curl -F 'access_token=APP_ACCESS_TOKEN' \
-F 'message=From the app to the user.' \
https://graph.facebook.com/USER_ID/apprequests

只能从收件人(USER_ID)使用用户访问令牌实现相同:

The same can be achieve using the User Access Token from the recipient (USER_ID) only:

curl -F 'access_token=USER_ACCESS_TOKEN' \
-F 'message=From the app to the user.' \
https://graph.facebook.com/USER_ID/apprequests

在JS SDK中,如果没有访问令牌字段被添加,默认的访问令牌将是登录的用户。了解到,向登录用户发送请求的上述呼叫将是:

In the JS SDK, if no Access Token field is added, the default Access Token will be of the logged in user. Knowing that, the above call which send the a request to the logged in user, will be:

FB.api('/me/apprequests', 'POST',  {message: 'From the app to the user.'});

第一次调用也可以通过JS SDK完成,通过在参数中添加App Access Token 。但是,这是一个不要使用的情况,因为您不想共享您的App Access令牌客户端。

The first call can also be done with the JS SDK, by adding the App Access Token in the parameters. However, this is a DO NOT USE case as you don't want to share your App Access token client-side.

这篇关于向“/ me”发送请求2.0应用生成的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆