Advertisement
nicolaslagios

get_data.php Collezione

Jan 24th, 2020 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. <?php
  2. $curl = curl_init();
  3.  
  4. curl_setopt_array($curl, array(
  5.   CURLOPT_PORT => "8050",
  6.   CURLOPT_URL => "http://188.164.204.222:8050/api/login",
  7.   CURLOPT_RETURNTRANSFER => true,
  8.   CURLOPT_ENCODING => "",
  9.   CURLOPT_MAXREDIRS => 10,
  10.   CURLOPT_TIMEOUT => 30,
  11.   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  12.   CURLOPT_CUSTOMREQUEST => "POST",
  13.   CURLOPT_POSTFIELDS => "{\n            SubscriptionPassword:  \"passx\",\n            model: {\n                                                                        BranchID: \"1\",\n                                                                        LangID: \"el-GR\",\n                                                                        Password: \"P@ssw0rd\",\n                                                                        UserID: \"webadmin\"\n            }\n  }",
  14.   CURLOPT_HTTPHEADER => array(
  15.     "content-type: application/json"
  16.   ),
  17. ));
  18.  
  19. $response = curl_exec($curl);
  20. $err = curl_error($curl);
  21.  
  22. curl_close($curl);
  23.  
  24. //παλαιος κωδικας δουλευει αλλα βγαζει οθονη
  25. if ($err) {
  26.   echo "cURL Error #:" . $err;
  27. } else {
  28.   $arr = json_decode($response, true);
  29.   $token = $arr['Model']['WebApiToken'];
  30. }
  31.  
  32. $curl = curl_init();
  33.  
  34. curl_setopt_array($curl, array(
  35.   CURLOPT_PORT => "8050",
  36.   CURLOPT_URL => "http://188.164.204.222:8050/api/rpc/PublicQuery/ESMobileQueries/KHC_WS_Products",
  37.   CURLOPT_RETURNTRANSFER => true,
  38.   CURLOPT_ENCODING => "",
  39.   CURLOPT_MAXREDIRS => 10,
  40.   CURLOPT_TIMEOUT => 30,
  41.   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  42.   CURLOPT_CUSTOMREQUEST => "POST",
  43.   CURLOPT_POSTFIELDS => "",
  44.   CURLOPT_HTTPHEADER => array(
  45.     "authorization: Bearer ${token}"
  46.   ),
  47. ));
  48.  
  49. $response2 = curl_exec($curl);
  50. $err2 = curl_error($curl);
  51.  
  52. curl_close($curl);
  53.  
  54. if ($err2) {
  55.   echo "cURL Error #:" . $err2;
  56. } else {
  57.   /*var_dump(json_decode($response2, true));*/
  58.   echo $responce2;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement