参考文档:
- PHP调用拼多多API模板https://blog.csdn.net/qq_35056934/article/details/79849898
- 沈哥提供的简易登录模板
///简易登录S////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1 //index.php文件 2 <?php 3 4 $data["code"] = $_GET["code"]; 5 $data["grant_type"] = "authorization_code"; 6 $data["client_id"] = "fea8cf1cfc75421e929115902f5a60cb"; 7 $data["client_secret"] = "286933c544380ac846be5f2938b7f276dee85132"; 8 9 $arr_header[] = "Content-Type:application/json"; 10 $res = http_request_post("http://open-api.pinduoduo.com/oauth/token",json_encode($data),true,$arr_header); 11 12 echo $res;//token信息等 13 14 /** 15 * curl post请求函数 16 * 17 * 18 * @url 请求的地址 19 * @data 传输的数据 20 * @json 是否json传输 21 * @arr_header 请求头信息 22 * 23 * */ 24 function http_request_post($url,$data = null,$json = false,$arr_header = null){ 25 $curl = curl_init(); 26 curl_setopt($curl, CURLOPT_URL, $url); 27 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); 28 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); 29 if (!empty($data)){ 30 31 if ($json && is_array($data)) { 32 $data = json_encode($data); 33 } 34 curl_setopt($curl, CURLOPT_POST, 1); 35 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 36 } 37 if(!empty($arr_header)){ 38 curl_setopt($curl, CURLOPT_HTTPHEADER, $arr_header); 39 } 40 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 41 $output = curl_exec($curl); 42 // echo curl_getinfo($curl); 43 curl_close($curl); 44 unset($curl); 45 return $output; 46 }
1 <!-- login.html --> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 <title>登陆</title> 7 </head> 8 <body> 9 <a href="https://mms.pinduoduo.com/open.html?response_type=code&client_id=fea8cf1cfc75421e929115902f5a60cb&redirect_uri=http://pdd.shanyanzhineng.com&state=">登陆</a> 10 11 </body> 12 </html>
///简易登录E////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////