Files
dev-chiefworks 855bf9ac9c fix
2022-04-20 20:40:23 -04:00

81 lines
3.0 KiB
PHP

<?php
namespace App\Services;
use GuzzleHttp\Client as HTTPClient;
//use \\CoreServiceApi;
class UserProfile extends CoreServiceApi
{
public static function floatUserProfile($token)
{
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://10.20.30.26:8000/api/v1/user/profile');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 0);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"username\":\"test@float.sg\",\"password\":\"111111\",\"sessionid\":\"DUMMYSESSION\"}");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = 'X-Devicetoken: ';
$headers[] = 'X-Float-Device-Location-Latitude: 0';
$headers[] = "Authorization: Token {$token}";
$headers[] = 'Content-Type: application/json';
$headers[] = 'Accept: application/json, text/plain, */*';
$headers[] = 'X-Float-Device-Location-Longitude: 0';
$headers[] = 'Referer: http://10.0.0.252:8100/';
$headers[] = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36';
$headers[] = 'X-Session-Id: ';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
return $result;
// $apiEndpointsConfig = config('ApiEndpoints');
// $baseUrl = $apiEndpointsConfig->baseUrl;
// $username = $apiEndpointsConfig->clientCredentials['username'];
// $password = $apiEndpointsConfig->clientCredentials['password'];
$client = new HTTPClient();
$baseUrl = "http://10.20.30.26:8000/api/v1/profile";
$headers = array();
$headers[] = 'X-Devicetoken: ';
$headers[] = 'X-Float-Device-Location-Latitude: 0';
$headers[] = "Authorization: Token {$token}";
$headers[] = 'Content-Type: application/json';
$headers[] = 'Accept: application/json, text/plain, */*';
$headers[] = 'X-Float-Device-Location-Longitude: 0';
$headers[] = 'Referer: http://10.0.0.252:8100/';
$headers[] = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36';
$headers[] = 'X-Session-Id: ';
$response = $client->request(
'POST',
"{$baseUrl}/login",
[
'headers' => $headers,
'body' => json_encode( ["username"=>"test@float.sg",
"password"=>"111111",
"sessionid"=>"DUMMYSESSION"] )
]
);
//$response = json_decode($response->getBody(), true);
return $response;
}
}