Home > Backend Development > PHP Tutorial > Code for POST data to API interface using CURL method under PHP_PHP Tutorial

Code for POST data to API interface using CURL method under PHP_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:12:54
Original
836 people have browsed it

Actually, it is relatively simple. Upload the code:

Copy the code The code is as follows:


$url = 'http://127.0.0.1/test.php';//The link pointed to by POST
$data = array(
'access_token'=>'thekeyvalue'
);  

 $json_data = postData($url, $data);    
 $array = json_decode($json_data,true); ; ;

function postData($url, $data)
{ $ch = curl_init();
$timeout = 300; topt($ch, CURLOPT_URL, $url ; ch, CURLOPT_POSTFIELDS, $data); 
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
$handles = curl_exec($ch);
curl_close($ch);                                                                                                                                                                                



http://www.bkjia.com/PHPjc/326623.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/326623.html
TechArticle

Actually, it’s relatively simple, just upload the code: Copy the code and the code is as follows: ?php $url = 'http:// 127.0.0.1/test.php';//The link pointed to by POST $data = array( 'access_token'='thekeyvalue' ); $jso...

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
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template