Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = 'xxx';
- $password = 'xxx';
- $userpass = $username . ":" . $password;
- $headers=array(
- 'Authorization: Basic '. base64_encode($userpass),
- 'Accept: */*',
- 'Accept-Encoding: gzip, deflate'
- );
- const ECSET_AUTH = 'xxx';
- if(isset($_REQUEST['ecset'])){
- SendEcset($_REQUEST['ecset']);
- }
- function SendEcset($ecset){
- global $headers, $username, $password;
- $params = array(
- "client_id" => "xxx",
- "client_secret" => "xxx",
- "grant_type" => "client_credentials",
- );
- $curl = curl_init(ECSET_AUTH);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_HEADER, true);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_HEADER,'Content-Type: application/x-www-form-urlencoded');
- $postData = "";
- foreach($params as $k => $v)
- {
- $postData .= $k . '='.urlencode($v).'&';
- }
- $postData = rtrim($postData, '&');
- curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
- echo "Performing Request...";
- $json_response = curl_exec($curl);
- $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- if ($status != 200) {
- throw new Exception("Error: call to URL $endpoint failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl) . "\n");
- }
- curl_close($curl);
- return $json_response;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement