【发布时间】:2014-05-06 10:09:46
【问题描述】:
我有 0 次 curl 经验,我想运行一个请求,该请求将在 php 中返回一个 json 正文。
使用 firefox firbug 我可以复制 curl 命令,它看起来像这样
curl 'http://*****.com/index.php/home/search/keyword/c815f2fec5?value=keyworkd' -H
'Host: *****.com' -H
'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0' -H
'Accept: */*' -H
'Accept-Language: en-US,en;q=0.5' -H
'Accept-Encoding: gzip, deflate' -H
'X-Requested-With: XMLHttpRequest' -H
'Referer: http://****.com/' -H
'Cookie: _ga=GA1.2.373422434.1399222050; PHPSESSID=l8sf036kjaijt6cjvcqnu992l4'
我可以用 php 模拟这样的请求吗?
【问题讨论】:
-
你不能(理智地)在 PHP 中使用 cURL 命令行。您需要使用 PHP-cURL API 重写它。手册是here。
-
是的,我知道!,我正在询问编写此类请求的 php 代码