Skip to content

Instantly share code, notes, and snippets.

@lamguy
Created October 26, 2017 18:28
Show Gist options
  • Select an option

  • Save lamguy/f5ffda94b061632fa6ddfdfba0fc74af to your computer and use it in GitHub Desktop.

Select an option

Save lamguy/f5ffda94b061632fa6ddfdfba0fc74af to your computer and use it in GitHub Desktop.
Request GSMA
<?php
$imei = "354408064463695";
$apiKey = 'C31xxx950';
$password = 'paxxx#d';
$salt = 'Dxxx';
$orgID = 187;
$secret = 'GSxxxion';
$signatureHash = hash("sh256", $apiKey . $password . $imei);
$text = $salt . $orgID . "=" . $signatureHash;
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-ecb'));
$authorisation = openssl_encrypt($text, 'aes-256-ecb', $secret, 0, $iv);
$header = array();
$header[] = 'Content-type: application/x-www-form-urlencoded';
$header[] = 'Authorisation: ' . $authorisation;
//CREATE PAYLOAD
$payload = ['deviceid' => $imei];
// SET CURL URL
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
//DESIGNATE AS A POST REQUEST
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
// Timeouts
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
//EXECUTE REQUEST
$rawResponse = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment