Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function test(){
- $curl = curl_init();
- $obj = ['email' => "tester3@g.c", "password" => "gogogo"];
- $data = json_encode($obj);
- curl_setopt_array($curl, array(
- CURLOPT_URL => "http://simplerest.lan/auth/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 => $data,
- CURLOPT_HTTPHEADER => array(
- "Accept: */*",
- "Accept-Encoding: gzip, deflate",
- "Cache-Control: no-cache",
- "Connection: keep-alive",
- "Content-Length: ". strlen($data),
- "Content-Type: text/plain",
- "Host: simplerest.lan",
- "cache-control: no-cache"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- // Check HTTP status code
- if ($err){
- var_dump($err);
- var_dump('Unexpected HTTP code: '. $http_code);
- }
- var_dump(json_decode($response));
- var_dump('HTTP code: '. $http_code);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement