Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_PORT => "8050",
- CURLOPT_URL => "http://188.164.204.222:8050/api/login",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "{\n SubscriptionPassword: \"passx\",\n model: {\n BranchID: \"1\",\n LangID: \"el-GR\",\n Password: \"P@ssw0rd\",\n UserID: \"webadmin\"\n }\n }",
- CURLOPT_HTTPHEADER => array(
- "content-type: application/json"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- //παλαιος κωδικας δουλευει αλλα βγαζει οθονη
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- $arr = json_decode($response, true);
- $token = $arr['Model']['WebApiToken'];
- }
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_PORT => "8050",
- CURLOPT_URL => "http://188.164.204.222:8050/api/rpc/PublicQuery/ESMobileQueries/KHC_WS_Products",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "",
- CURLOPT_HTTPHEADER => array(
- "authorization: Bearer ${token}"
- ),
- ));
- $response2 = curl_exec($curl);
- $err2 = curl_error($curl);
- curl_close($curl);
- if ($err2) {
- echo "cURL Error #:" . $err2;
- } else {
- /*var_dump(json_decode($response2, true));*/
- echo $responce2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement