php - 如何为 Web 服务创建代理 [英] php - how to make a proxy for a web service
问题描述
我正在尝试通过构建本地代理来解决 Web 服务的访问控制源错误,但我不知道该怎么做.Web 服务看起来像附加文件,可以使用以下 URL 直接访问:
,或者设置一个 stream 来配置和执行 POST.
I'm trying to get around an access control origin error for a web service by building a local proxy, but I'm not sure how to do it. The web service looks like the attached file, and is accessed directly by using the following URL:
https://url.com/SparkService.asmx?op=InsertConsumer
How would I write something locally that carried out this URL's functionality?
I built a PHP file that will pull the web service URLs contents, but it doesn't seem to carry out the functionality of that web service:
<?php
$op = htmlspecialchars($_GET["op"]);
$proxyURL = 'https://url.com/SparkService.asmx?op=' . $op;
die( file_get_contents($proxyURL) );
?>
The image shows you have to use a POST, which you can't do with bare-bones file_get_contents - it defaults to using a GET query. You'll have to use CURL, or set up a stream to configure and perform a POST.
这篇关于php - 如何为 Web 服务创建代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!