59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Utilities;
|
|
|
|
class ApiCalls
|
|
{
|
|
/**
|
|
* Create a new class instance.
|
|
*/
|
|
|
|
public static function CurlGet($url){
|
|
$get_url = env('APIBASEURL') . $url;
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => $get_url,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
curl_close($curl);
|
|
return $response;
|
|
|
|
}
|
|
public static function CurlPost($data, $url){
|
|
$post_url = env('APIBASEURL') . $url;
|
|
$curl = curl_init();
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => $post_url,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
CURLOPT_POSTFIELDS => $data,
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Content-Type: application/json'
|
|
),
|
|
));
|
|
$response = curl_exec($curl);
|
|
curl_close($curl);
|
|
return $response;
|
|
}
|
|
|
|
|
|
public static function generatePassword($length = 10) {
|
|
return bin2hex(random_bytes($length / 2));
|
|
}
|
|
}
|