cloudtuts

Untitled

Sep 23rd, 2020 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. $strPostURL='網站根目錄';
  2. $arrData=array(
  3.     //'email'       =>'jana@jana.bz', // WordPress 帳號 email
  4.     'mobile'        =>'0932888999',
  5.     'user-id'   =>'janalee.tw', // 自訂 user-id
  6.     'action'    =>'custom-user-id',
  7. );
  8.  
  9. $ch=curl_init();
  10.  
  11. curl_setopt($ch, CURLOPT_URL, $strPostURL);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  13. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
  14.  
  15. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arrData));
  16.  
  17. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
  18.  
  19. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  20. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  21.  
  22. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  23.  
  24. $response=curl_exec($ch);
  25.  
  26. if(curl_errno($ch)){
  27.     $response['error']      =true;
  28.     $response['message']    =curl_error($ch);
  29. }
  30.  
  31. curl_close($ch);
  32.  
  33. // 回傳資料範例: {"status":"OK","message":"\u66f4\u65b0\u5b8c\u6210"}
Add Comment
Please, Sign In to add comment