It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
/*
* Server REST - user.login
*/
// REST Server URL
$request_url = 'http://exchange.zapto.org/api/user/login';
// User data
$user_data = array(
'username' => 'name',
'password' => 'pass',
);
$user_data = json_encode($user_data);
// cURL
$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json')); // Accept JSON response
curl_setopt($curl, CURLOPT_POSTFIELDS, $user_data); // Set POST data
curl_setopt($curl, CURLOPT_HEADER, FALSE); // Ask to not return Header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check if login was successful
if ($http_code == 200) {
// Convert json response as array
$logged_user = json_decode($response);
}
else {
// Get error msg
$http_message = curl_error($curl);
die($http_message);
}
echo 'Login successful';
// Define cookie session
$cookie_session = $logged_user->session_name . '=' . $logged_user->sessid;
$index_url = 'http://exchange.zapto.org/api/ccaccount';
$curl = curl_init($index_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); // use the previously saved session
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json')); // Accept JSON response
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check if login was successful
if ($http_code == 200) {
// Convert json response as array
$accounts = json_decode($response);
}
else {
// Get error msg
$http_message = curl_error($curl);
die($http_message);
}
/*
* Server REST - ccaccount.withdraw
*/
// Withdraw parameters
$id = '' ;
// the address where to send to coins
$withdraw_address = 'LZaau3jFx7wMP6hMrH3UsxBiLk4R6q6uFF';
// the amount
$amount = '20.0';
// a timestamp
$timestamp = time();
// Build the data string to sign
$data = $id."_". $withdraw_address ."_".$amount."_".$timestamp;
// variable which holds the signature
$signature = '';
// let openssl sign our data with the key provided in file (the one received from the server)
openssl_sign($data, $signature, file_get_contents('/home/klinkigt/code/drupal/cryptocoin/modules/cryptocoin_api/martin.pem'));
// REST Server URL
$request_url = 'http://exchange.zapto.org/api/ccaccount/'.$id.'/withdraw';
// Withdraw data
// base64 encode the signature once!
// id is not read from the array! call the proper URI including the account id
$withdraw_data = array(
'withdraw_address' => $withdraw_address,
'amount' => $amount,
'timestamp' => $timestamp,
'sign' => base64_encode($signature),
);
$withdraw_data = json_encode($withdraw_data);
// cURL
$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $withdraw_data); // Set POST data
curl_setopt($curl, CURLOPT_HEADER, FALSE); // Ask to not return Header
curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); // use the previously saved session
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json')); // Accept JSON response
$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check if login was successful
if ($http_code == 200) {
// Convert json response as array
$withdraw = json_decode($response);
}
else {
// Get error msg
$http_message = curl_error($curl);
die($http_message);
}
print_r($withdraw);