-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response No JSON object could be decoded #14
Comments
Hi, I tried your code and I got "No JSON object could be decoded" as well. I still don't know the reason, but I suspect it is something related to <?php
// @param {array} $message
function send($message)
{
$message = json_encode($message);
// Trade API URL
$url = 'https://api.testnet.blinktrade.com/tapi/v1/message';
// Set API Key and Secret
$key = 'MvkISyWHJN1vCqJtpRkc35l30U7X9wZaiTJhj6nOIlQ';
$secret = '7DWNrwycvs2jgDYn6SPrQDuAz1qIlsrHAmgKhB2UeJE';
// Generate a nonce
$nonce = strval(time());
// Sign the nonce with secret using HMAC-SHA256
$signature = hash_hmac('sha256', $nonce, $secret);
// Define headers
$headers = [
'APIKey:' . $key,
'Nonce:' . $nonce,
'Signature:' . $signature,
'Content-Type:application/json'
];
// Send a POST message to API URL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = send([
'MsgType' => 'U2',
'BalanceReqID' => 1
]);
print_r(json_decode($response, true)); Output:
|
I have the same issue using Refit for C#. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello guys, I am trying to make a request, but I have not had any success, I always send my fix in Json format but I always get the same answer, how can I solve this?
The small code is written in php using the laravel framework 5.4.3
Thank you very much for your help
The text was updated successfully, but these errors were encountered: