php對接登陸的三兩片語

來源:互聯網
上載者:User

標籤:for   form   token   ret   signature   timestamp   客戶   secret   cli   

$client_id=‘‘;$sign_method=‘MD5‘;$version=‘1.0‘;$timestamp=time();//時間戳記$client_secret=‘‘;//客戶證明$code = $_GET[‘code‘];$grant_type = ‘authorization_code‘;$sign_sort = ‘client_id&sign_method&version&timestamp&client_secret&code&grant_type‘;$signature = md5($client_id.$sign_method.$version.$timestamp.$client_secret.$code.$grant_type);//md5簡要加密$data = array(  ‘client_id‘=>$client_id,  ‘sign_method‘=>$sign_method,  ‘version‘=>$version,  ‘timestamp‘=>$timestamp,  ‘client_secret‘=>$client_secret,  ‘code‘=>$code,  ‘grant_type‘=>$grant_type,  ‘sign_sort‘=>$sign_sort,  ‘signature‘=>$signature  );$urlencodeData = http_build_query($data);//array轉urlencode$url =‘‘;//code換token的地址$ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_HTTPHEADER,array(‘Content-Type:application/x-www-form-urlencoded‘));//https、tttp要求標頭設定,視情況而定curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);//是否對認證認證來源的檢查curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//以檔案流輸出執行結果//將伺服器伺服器返回的"Location: "放在header中遞迴的返回給伺服器,使用CURLOPT_MAXREDIRS可以限定遞迴返回的數量。視情況而定//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);curl_setopt($ch,CURLOPT_POST,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$urlencodeData);$json = curl_exec($ch);curl_close($ch);$arr = json_decode($json);

拿到你要的token。

重點注意:對於不同的接入,每個接入的加密和擷取token請求的方式有所不同。

php對接登陸的三兩片語

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.