Home > php教程 > php手册 > body text

一段简单的curl代码

WBOY
Release: 2016-06-06 20:14:54
Original
944 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:
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 Recommendations
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!