使用.getJSON什么时候能得到Play商店应用详细信息获取跨产地块请求[CORS]错误详细信息、什么时候、地块、商店

2023-09-10 14:13:59 作者:桀骜过分

所以基本上我是用42matters.com APP市场的API来获取从谷歌Play商店应用程序的详细信息或资料,一切工作正常,我居然也得到了JSON响应回来,但是当我回到办公室的周末假期后,这个相当奇怪的错误来了,正在返回任何内容。

So basically i was using 42matters.com APP market API to get the app details or information from the google play store, everything was working fine and i was getting the JSON response back, but when i came back to office after weekend holidays, this rather strange error came and nothing was being returned.

我已经使用$ .getJSON功能,如:

I have used $.getJSON function like:

var packageID = 'com.whatsapp';
   $.getJSON('https://42matters.com/api/1/apps/lookup.json?p='+packageID+'&access_token=accesstoken1234')
.done(function(appDetails) {
            $('#logo').html(JSON.stringify(appDetails));
        });

如前所述这是返回数据,我能够相应地改变一切,但现在它在所有给我无缘无故此错误

As mentioned this was returning the data and i was able to change everything accordingly but now it is giving me this error for no reason at all

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://42matters.com/api/1/apps/lookup.json?p=com.whatsapp&access_token=accesstoken1234. This can be fixed by moving the resource to the same domain or enabling CORS

我已经启用了CORS使用PHP,并没有什么happended,试图改变的Apache conf文件,使CORS存在,但该服务不会与此重新启动,所以我卡住了。

i have enabled the CORS using PHP, and nothing happended, tried to change the conf file of apache to enable CORS there but the service wont restart with this, so i am stuck.

还有一件事,当我手动输入在浏览器上面的链接,它确实给了期望的结果。请帮我解决这个问题。

One more thing, when i manually enter the above link in the browser, it does give the desired result. Please help me resolve it

推荐答案

CORS被挡在浏览器端,将不允许AJAX从另一个域请求数据。您应该联系42matters.com球队打开的crossdomain.xml你喜欢这个 CORS jQuery的AJAX请求或Can有人张贴以及形成的crossdomain.xml样?

CORS is blocked in browser side that won't allow AJAX to request data from another domain. You should contact the 42matters.com team to open the crossdomain.xml for you like this CORS jQuery AJAX request or Can someone post a well formed crossdomain.xml sample?

或者解决办法对AJAX跨域JSONP: jQuery的AJAX跨域但API应该支持这种要求。

Or the workaround for AJAX Cross-Domain is JSONP: jQuery AJAX cross domain but the API should support this kind of request.

的最后一件事是不使用AJAX来从其他来源收集数据,如果是移动平台,它应该有本地的HTTP请求对象来做到这一点。

The last thing is don't use AJAX to collect data from another sources, if it is mobile platform, it should have native HTTP Request object to do this