-2

我尝试在 php 中使用 cURL 来获取一个 xml 文件,该 url 是http://game1-cbt.ma.sdo.com:10001/connect/app/exploration/fairyhistory?cyt=1,但返回的字符串是混乱的. 我用谷歌搜索并尝试了 curl_setopt($c, CURLOPT_ENCODING, '');,但它仍然不起作用。显示的内容没有改变。这是我的完整程序

$url = "http://game1-cbt.ma.sdo.com:10001/connect/app/exploration/fairyhistory";
$ua="Million/100 (m0; m0xx; 4.2.2) samsung/m0xx/m0:4.2.2/JDQ39/I9300XXUFME3:user/release-keys";
$cookies = "S=85g158t9j3t4hi6kmcf47rbjh1";
$c = curl_init();
curl_setopt($c,CURLOPT_URL,$url);
curl_setopt($c,CURLOPT_HEADER,0);
curl_setopt($c,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($c,CURLOPT_USERAGENT,$ua);
curl_setopt($c, CURLOPT_ENCODING, '');
curl_setopt($c,CURLOPT_COOKIE,$cookies);

$r = curl_exec($c);

echo $r;

更新:

它适用于带有 UA 注释的行。谢谢你们!

PS:UA是我从一个手机网游中截取的一个包,我正在尝试模拟游戏的动作。

4

2 回答 2

0
$url = "http://game1-cbt.ma.sdo.com:10001/connect/app/exploration/fairyhistory";
$ua = "Million/100 (m0; m0xx; 4.2.2) samsung/m0xx/m0:4.2.2/JDQ39/I9300XXUFME3:user/release-keys";
$cookies = "S=85g158t9j3t4hi6kmcf47rbjh1";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($c, CURLOPT_USERAGENT, $ua); - you don't need this
curl_setopt($c, CURLOPT_ENCODING, '');
curl_setopt($c, CURLOPT_COOKIE, $cookies);
$r = curl_exec($c);

echo $r;
于 2013-10-07T05:59:14.200 回答
0

curl_setopt($c,CURLOPT_USERAGENT,$ua); 这段代码变坏了 删除它,最好使用另一个UA

如果删除它在我的测试中工作curl_setopt($c,CURLOPT_USERAGENT,$ua);

请注意,如果您直接在浏览器中回显此内容,请检查源(查看源)以符合

于 2013-10-07T06:06:28.590 回答