请教 curl 命令在PHP中如何用
Jun 13, 2016 pm 01:23 PM
请问 curl 命令在PHP中怎么用
如下
curl -X POST -v -c cookies.txt -d "{\"username\":\"uname\",\"password\":\"pas word\"}" -H "Content-Type: application/json" xxx.com/ah/session
这个命令
在PHP中如何使用以上命令?
谁能提供完整的示例,小弟感激不禁~~~~~~~~~
------解决方案--------------------
// 1. 初始化
$ch = curl_init();
// 2. 设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, "http://www.nettuts.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
// 3. 执行并获取HTML文档内容
$output = curl_exec($ch);
// 4. 释放curl句柄
curl_close($ch);
------解决方案--------------------
http://www.chinaz.com/program/2010/0119/104346_2.shtml
------解决方案--------------------

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to realize the mutual conversion between CURL and python requests in python

Tutorial on updating curl version under Linux!

PHP8.1 released: Introducing curl for concurrent processing of multiple requests

From start to finish: How to use php extension cURL to make HTTP requests

How to handle 301 redirection of web pages in PHP Curl?

Solution to PHP Fatal error: Call to undefined function curl_setopt()

In-depth understanding of the 301 jump mechanism in PHP Curl
