繁体   English   中英

AngularJS http.jsonp无法从自定义PHP代理响应中找到JSON_CALLBACK

[英]AngularJS http.jsonp can't find JSON_CALLBACK from custom PHP proxy response

我正在尝试从Readability获得一个简单的JSON答复,使用直接链接到Readability的API可以正常工作,例如:

$http.jsonp('https://www.readability.com/api/content/v1/parser?url='+url+'&token='+token+'&callback=JSON_CALLBACK').success(function(data) { ... etc

但是在使用我自己的“代理”时不起作用:

<?php
    header('Content-Type: application/json');
    print file_get_contents('https://www.readability.com/api/content/v1/parser?url='.urlencode($_GET['url']).'&token='.$token.'&callback=JSON_CALLBACK');
?>

与:

$http.jsonp('parser.php?url='+url).success(function(data) { ...

我也尝试过使用curl和复制所有标头,等等。我不明白,为什么http.jsonp不能从我自己的代理中找到变量JSON_CALLBACK?

JSON_CALLBACK被调用时更换angular.callbackSomething和你的PHP使用硬编码JSON_CALLBACK所以当角度尝试运行callbackSomething没有从JSONP功能用这种方法,希望是有道理

print file_get_contents('https://www.readability.com/api/content/v1/parser?url='.urlencode($_GET['url']).'&token='.$token.'&callback='.$_GET['callback']);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM