<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$varURL);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 95);
$varResult = curl_exec($ch);
?>
但我把echo $ varURL;并复制网址和粘贴在浏览器网址我有短信成功,但在卷曲exec它不工作
答案 0 :(得分:0)
只有浏览器请求中缺少的是User-Agent:
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0");
此外,运行启用了VERBOSE
模式的代码,以便您可以自己查看。
curl_setopt($ch, CURLOPT_VERBOSE, true);