PHP uses the CURL method to POST data to the API code. In fact, it is relatively simple. run the code: Copy the code as follows :? Php $ url127.0.0.1test. php; POST points to the link $ dataarray (access_tokenthekeyvalue); $ jso is actually relatively simple. the code is as follows:
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 );
Echo'
'; Print_r ($ array );
Function postData ($ url, $ data)
{
$ Ch = curl_init ();
$ Timeout = 300;
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_REFERER, "http://www.jb51.net/"); // Construct a path
Curl_setopt ($ ch, CURLOPT_POST, true );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout );
$ Handles = curl_exec ($ ch );
Curl_close ($ ch );
Return $ handles;
}
?>
The pipeline 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...