Bitcoin Forum
November 10, 2024, 09:23:56 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Working with spectrocoin's API  (Read 144 times)
freeman1177 (OP)
Newbie
*
Offline Offline

Activity: 20
Merit: 0


View Profile
July 01, 2018, 02:54:27 PM
 #1

Did anyone worked with spectrocoin's API. I am trying to send bitcoins using their API and I'm getting some error.

I've written this php code, when running I'm getting the error [{"code":99,"message":"Please check your request"}] when refreshing the token and [{"code":100,"message":"Unexpected error"}] when sending bitcoins


Code:
// auth
$url = 'https://spectrocoin.com/api/r/oauth2/auth';

$ch = curl_init($url);

$jsonData = array(
'client_id' => 'wallet_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'client_secret' => 'xxxxxxxx',
'version' => '1.0',
'scope' => 'send_currency currency_exchange user_account'
);

$jsonDataEncoded = json_encode($jsonData);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Connection: Keep-Alive',
'Content-Length: '.strlen($jsonDataEncoded),
'Content-Type: application/json',
'Host: spectrocoin.com'
));

$result = curl_exec($ch);

$manage = explode(":",$result);

$manageB = explode('"',$manage[1]);
$manageC = explode('"',$manage[4]);
$accessToken = $manageB[1];
$refreshToken = $manageC[1];


// refresh
$url = 'https://spectrocoin.com/api/r/oauth2/refresh';

$ch = curl_init($url);

$jsonData = array(
'client_id' => 'wallet_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'client_secret' => 'xxxxxxxx',
'version' => '1.0',
'scoperefresh_token' => $refreshToken
);

$jsonDataEncoded = json_encode($jsonData);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Connection: Keep-Alive',
'Content-Length: '.strlen($jsonDataEncoded),
'Content-Type: application/json',
'Host: spectrocoin.com'
));

$result = curl_exec($ch);



echo $result;




// send
$url = 'https://spectrocoin.com/api/r/wallet/send/BTC';

$ch = curl_init($url);

$jsonData = array(
'amount' => '0.00000600',
'receiver' => '1DnWpp7AeM69w14MU5TXWUSERrhWFEtP92'
);

$jsonDataEncoded = json_encode($jsonData);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$accessToken ,
'Connection: Keep-Alive',
'Content-Length: '.strlen($jsonDataEncoded),
'Content-Type: application/json',
'Host: spectrocoin.com'
));
$result = curl_exec($ch);

freeman1177 (OP)
Newbie
*
Offline Offline

Activity: 20
Merit: 0


View Profile
July 06, 2018, 07:31:59 AM
 #2

Resolved
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!