【发布时间】:2015-06-29 11:18:36
【问题描述】:
我正在尝试使用此处找到的 Twitch API:https://github.com/justintv/Twitch-API,他们提到“All API methods support JSON-P by providing a callback parameter with the request.”我正在使用 angularJS,经过一些研究,我发现无法使用 POST 请求JSONP 调用(How to make a JSONP POST request in angular?)。
API 的身份验证部分要求我这样做:
Step 3:On your server, you can now make the following request to obtain an access token:
POST https://api.twitch.tv/kraken/oauth2/token
POST Body (URL-encoded)
client_id=[your client ID]
&client_secret=[your client secret]
&grant_type=authorization_code
&redirect_uri=[your registered redirect URI]
&code=[code received from redirect URI]
Step 4. We'll respond with a JSON-encoded access token...
如果不可能,我应该如何使用 JSONP 发出 POST 请求? 我错过了什么?
【问题讨论】:
-
发布请求必须来自服务器而不是客户端。您不想泄露 clientid\secret 所以这必须在服务器上完成。
-
这是否意味着我应该调用一个 PHP 脚本来为我做这件事?我想我可能不明白其中的区别。
-
是的,在服务器上使用您使用的任何服务器平台,例如 php