公司内网环境访问外网需要通过代理,彩信接口在外网环境已经调通,怎么通过curl访问代理服务器访问外网

WBOY
Release: 2016-06-13 12:03:34
Original
1488 people have browsed it

公司内网环境访问外网需要通过代理,彩信接口在外网环境已经调通,如何通过curl访问代理服务器访问外网
如题,彩信接口在外网状态下已经调通,但公司用的是内网,需要走代理服务器才能访问外网,彩信接口是通过curl post到指定地址的。
$url = 'http://122.200.77.96/sendMMS';
$header[] = "Content-type: text/xml";
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
$response = curl_exec($ch);
if(curl_errno($ch)){
    print curl_error($ch);
}
curl_close($ch);
这是post到彩信接口的代码,如何通过curl走代理服务器,再post到指定接口
------解决方案--------------------
curl_setopt($ch, CURLOPT_PROXY, $this->data['proxy']); 
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
用这两个 但是明明没错 我自己本地 也搞不出来 郁闷
------解决方案--------------------
curl_setopt($ch, CURLOPT_PROXY, "代理服务器地址:端口");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "用户名:口令"); //没有就不要这句

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!