Home > php教程 > php手册 > 一段简单的curl代码

一段简单的curl代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:14:54
Original
1013 people have browsed it

在移动后端开发中经常遇到需要对接口进行调试,使用curl可以带来很大的便捷,记录下我常用的一段代码方便以后重用 [代码片段]

在移动后端开发中经常遇到需要对接口进行调试,使用curl可以带来很大的便捷,记录下我常用的一段代码方便以后重用

$data = array('userid'=>123,'switch'=>array('msg_accept','msg_voice' ,'msg_vibrated')); $request = http_build_query($data); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,'http://localhost/system/sys.php'); curl_setopt($ch,CURLOPT_POST,TRUE); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); curl_setopt($ch,CURLOPT_POSTFIELDS,$request); echo __LINE__,'|',date('Y-m-d H:i:s'),PHP_EOL; $result = curl_exec($ch); echo __LINE__,'|',date('Y-m-d H:i:s'),PHP_EOL; var_dump($result); ,
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template