我建立一个Spotify应用,从一个REST API拉JSON数据,使用URL像
I'm building a Spotify App that pulls JSON data from a REST API, using URLs like
www.mydomain/api/command?option=value在我的Spotify应用清单,我设置了所需的权限为我的API主持人:
In my Spotify app manifest I have set the required permissions for my API host:
"RequiredPermissions": [ "*.mydomain" ]我也曾在我的API的响应头配置跨来源资源共享。这是一个真实的例子:
I have also configured Cross-Origin Resource Sharing in the response headers of my API. Here is a real example:
Server: nginx/0.7.65 Date: Thu, 08 Dec 2011 09:07:16 GMT Content-Type: application/json Connection: keep-alive X-Powered-By: Mojolicious (Perl) Set-Cookie: mojolicious=eyJwcmVmcyI6e30sImZpbHRlcnMiOnsicGllciI6eyJzb3VyY2VzIjpbMjBdfSwiZWxlYyI6eyJzb3VyY2VzIjpbMTMsMTddLCJ4dGFncyI6WyJzaG9lZ2F6ZSJdLCJ0YWdzIjpbImVsZWN0cm9uaWMiXX0sInB1bmtkdWIiOnsieHRhZ3MiOlsicmVnZ2FlIl0sInRhZ3MiOlsicHVuayIsImR1YiJdfX0sImV4cGlyZXMiOjEzMjMzMzg4MzZ9--c6d6214525b5d56785eebc99217394a1; Version=1; Path=/; expires=Thu, 08 Dec 2011 10:07:16 GMT Content-Length: 23381 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET Access-Control-Allow-Headers: * 200 OK在Spotify的,在Chrome网络督察选项卡中,我看到该请求被取消:
In Spotify, in the chrome inspector network tab, I see that the request is being cancelled:
Name: command www.mydomain/api Method: GET Status Text: (canceled) Type: undefined Initiator: jquery-1.js:7180 (Script) Size Content: 13B (0B) Time Latency: 21ms (0.0 days)
如果我在我的桌面上运行我在Chrome的应用程序(外的Spotify)的请求,不取消,一切都很好。
If I run my app in Chrome on my desktop (outside of Spotify) the request is not cancelled and all is good.
我是什么做错了吗?或者,也许这是Spotify的preVIEW释放错误(功能?)?
What am I doing wrong? Or maybe this is a bug (feature?) in Spotify preview release?
推荐答案一对夫妇的事情可能导致此,我会把他们为了从易到解析到最难的。
A couple of things can cause this, I'll put them in order from easiest to resolve to hardest.
最后,我想指出,即使请求有时在检查显示为取消,它仍然有一个正确的反应,所以一定要仔细检查这一点。
Lastly, I'd like to note that even though a request sometimes shows up in the inspector as cancelled, it'll still have a correct response, so be sure to double-check that as well.
希望这有助于!
编辑:有时候,出于某种奇怪的原因,这也有助于建立你的 RequiredPermissions 没有请求的URL 的http:// 或的https:// prepended
sometimes, for some weird reason, it also helps to set the url you're requesting in RequiredPermissions without the or prepended.
更多推荐
为什么JSON请求我的外部API在我的Spotify应用被取消?
发布评论