how to integrate coinbase api in php for transfer bitcoine - php

I want to transfer bitcoin through bitcoin address in PHP please share the proper link.
https://developers.coinbase.com/docs/merchants/payment-buttons

Try This code for transfer btc
$transaction = Transaction::send();
$transaction->setToBitcoinAddress('here btc address to transfer');
$transaction->setAmount(new Money(0.0010, CurrencyCode::BTC));
$transaction->setDescription('this is optional');
Hope it will work :
https://github.com/coinbase/coinbase-php

Here the code for php
please have a look
<?php
$guid = "GUID_HERE";
$firstpassword = "PASSWORD_HERE";
$secondpassword = "PASSWORD_HERE";
$amounta = "10000000";
$amountb = "400000";
$addressa = "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq";
$addressb = "1ExD2je6UNxL5oSu6iPUhn9Ta7UrN8bjBy";
$recipients = urlencode('{
"' . $addressa . '": ' . $amounta . ',
"' . $addressb . '": ' . $amountb . '
}');
$json_url = "http://blockchain.info/merchant/$guid/sendmany?password=$firstpassword&second_password=$secondpassword&recipients=$recipients";
$json_data = file_get_contents($json_url);
$json_feed = json_decode($json_data);
$message = $json_feed->message;
$txid = $json_feed->tx_hash;
?>

Related

PHP://Input is Empty

I'm messing around with writing a own bot for telegramm using hook.io to host the php script. The problem that I have is that file_get_contents("php://input") always seems to be empty, since the bot does not react if I try to do anything related to the update:
$updates = json_decode(file_get_contents('php://input') ,true);
if($updates['ok']){
//loop over all messages
foreach($updates['result'] as $key => $value){
if($value['message']['text']==="/test"){
$chat_id = $value['message']['chat']['id'];
$result = file_get_contents( $apiURL . $apiToken . '/sendMessage?chat_id=' . $chat_id . '&text=test');
}
}
}
Can anyone tell whats wrong with this one?
I corrected in this way:
$updates = json_decode(file_get_contents('php://input') ,true);
if($updates['update_id']){
if($updates['message']['text']==="/test"){
$chat_id = $updates['message']['chat']['id'];
$result = file_get_contents( $apiURL . $apiToken . '/sendMessage?chat_id=' . $chat_id . '&text=test');
}
}
the message is always one, so I deleted the foreach

Amazon API signature

I've been attempting to create a signature to amazons API service, however I keep getting
SignatureDoesNotMatch on all my attempts and I honestly can't see what I've done wrong. This is my code;
<?php
require_once('.config.inc.php');
$sercretAccessKey = "XXXXX";
$site = $_GET['site'];
$serviceUrl = "";
$signatureUrl = "";
//UK marketplace
$marketplaceIdNumber = "A1F83G8C2ARO7P";
date_default_timezone_set('America/Phoenix');
$serviceUrl = "https://mws.amazonservices.de/Orders/2013-09-01";
$signatureUrl = "mws.amazonservices.de";
// Get total from 31 days ago
$t1 = date("c", time()-31*24*60*60);
$AccessKey = "AWSAccessKeyId=" . urlencode("xxxxx");
$action = "&Action=" . urlencode("ListOrders");
$fulfillmentChannel = "&FulfillmentChannel.Channel.1=" . urlencode("MFN");
$updateAfter = "&LastUpdatedAfter=" . urlencode($t1);
$marketplaceId = "&MarketplaceId.Id.1=" . urlencode($marketplaceIdNumber);
$orderStatus1 = "&OrderStatus.Status.1=" . urlencode("Unshipped");
$orderStatus2 = "&OrderStatus.Status.2=" . urlencode("PartiallyShipped");
$sellerID = "&SellerId=" . urlencode("xxxx");
$signatureMethod = "&SignatureMethod=" . urlencode("HmacSHA256");
$signatureVersion = "&SignatureVersion=" . urlencode("2");
$timeStamp = "&Timestamp=" . urlencode(date("c"));
$version = "&Version=" . urlencode("2013-09-01");
$stringToSignature =
"POST\n" .
"$signatureUrl\n" .
"/Orders/2013-09-01\n" .
$AccessKey . $action . $fulfillmentChannel . $updateAfter . $marketplaceId . $orderStatus1 . $orderStatus2 . $sellerID . $signatureMethod . $signatureVersion . $timeStamp . $version;
$signatureCode = hash_hmac('sha256', $stringToSignature, $sercretAccessKey, true);
$signatureCodeBaseEncoded = base64_encode($signatureCode);
$signatureCodeEncoded = urlencode($signatureCodeBaseEncoded);
$signature = "&Signature=" . $signatureCodeEncoded;
$targetURL = $serviceUrl . "?" . $AccessKey . $action . $fulfillmentChannel . $updateAfter . $marketplaceId . $orderStatus1 . $orderStatus2 . $sellerID . $signatureMethod . $signatureVersion . $timeStamp . $version . $signature;
// create context
$context = array('header' => 'Content-Type: text/xml');
$ci = curl_init($targetURL);
curl_setopt($ci, CURLOPT_POST, 1);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ci, CURLOPT_POSTFIELDS,"xmlRequest");
$result = curl_exec($ci);
echo $result;
?>
In theory this should work. I've followed their tutorials and followed what their scratchpad told me. So my request should be in canonical format.
Any help would be great!
I should probably note that the only way I can get any response from amazon is through the german serviceurl.

update users table through object id without login in parse.com(USING REST API)

I want to update User table of DATA BROWSER using objectId(With out getting user to log in ) using following code.
But I am getting:
error({"code":101,"error":"object not found for update"})
can any one tell me what is wrong with this:
$className = "Classname";
$objectIdToEdit = $_SESSION['objectId'];
$url = 'https://api.parse.com/1/classes/' . $className . '/' . $objectIdToEdit;
$appId = '***********************';
$restKey = '***********';
$updatedData = '{"firstname":"Billie123"}';
$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_PORT,443);
curl_setopt($rest,CURLOPT_CUSTOMREQUEST,"PUT");
curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);
curl_setopt($rest,CURLOPT_POSTFIELDS,$updatedData);
curl_setopt($rest,CURLOPT_HTTPHEADER, array(
"X-Parse-Application-Id: " . $appId,
"X-Parse-Master-Key: " . $restKey,
"Content-Type: application/json")
);
$response = curl_exec($rest);
echo $response;
I solved problem my self ,URL I was using is to save data
$url = 'https://api.parse.com/1/classes/' . $className . '/' . $objectIdToEdit;
I just changed URL to update data and problem is solved
$url = 'https://api.parse.com/1/' . $className . '/' . $objectIdToEdit;
thanks Ghost for editing

Expedia API showing "cannot service this request.Authentication failure" error

I am new in EAN development. I am developing hotel booking system in PHP using EAN. I want to fetch the reservation details from EAN API.
Following is my code:
$itinerary = xxxxxx;
$cid = 55505;
$minorRev = 13;
$apiKey = "y2dfnyvwbwkvgth76hfjdej7";
$locale = "en_US";
$currencyCode = "USD";
$customerSessionId;
$customerUserAgent;
$customerIpAddress;
$url = "http:api.ean.com/ean-services/rs/hotel/v3/";
$urlBook = "https:book.api.ean.com/ean-services/rs/hotel/v3/";
$url = ($service == 'res') ? $urlBook : $url;
$url .= $service
. "?minorRev={$minorRev}"
. "&cid={$cid}"
. "&apiKey={$apiKey}"
. "&customerUserAgent=" . rawurlencode($customerUserAgent)
. "&customerIpAddress={$customerIpAddress}"
. "&customerSessionId={$customerSessionID}"
. "&locale={$locale}"
. "&currencyCode={$currencyCode}";
$xml = "
<HotelItineraryRequest>
<itineraryId>{$itinerary}</itineraryId>
<email>customer#mail.com</email>
</HotelItineraryRequest>
";
$curl = new Curl();
$info = $curl->exec($xml, $url, "ItinerarySearch");
print_r($info);
It showing the following error :
Cannot service this request.Authentication failure
What is the problem with this code. Is there any solution that how can I get Reservation details from EAN.
I use the demo php code library from expedia : http://developer.ean.com/code_library/samples/PHP_Booking
Thanks in advance.

Google API Get inbox emails using access_token?

I am able to get access_token for multiple permissions like emails, contacts, docs, etc. using oAuth 2.0. I have access_token
I got contacts using the following code.
$url = 'https://www.google.com/m8/feeds/contacts/default/full?max- results='.$max_results.'&oauth_token='.$access_token;
$response_contacts= curl_get_file_contents($url);
Now i want to get users Emails using this access_token.
i used this url . but it gives 401 unauthorized Error
$url = 'https://mail.google.com/mail/feed/atom&oauth_token='.$access_token;
$response_emails= curl_get_file_contents($url);
please guide me how can i get emails using access_token.
I've seen references to the Gmail feed using oauth_token as a request parameter. However, once I used the OAuth Playground I discovered that you need to pass your OAuth information as an Authorization header, as you'll see below.
<?php
$now = time();
$consumer = ...; // your own value here
$secret = ...; // your own value here
$nonce = ...; // same value you've been using
$algo = "sha1";
$sigmeth = "HMAC-SHA1";
$av = "1.0";
$scope = "https://mail.google.com/mail/feed/atom";
$path = $scope;
$auth = ...; // an object containing outputs of OAuthGetAccessToken
$args = "oauth_consumer_key=" . urlencode($consumer) .
"&oauth_nonce=" . urlencode($nonce) .
"&oauth_signature_method=" . urlencode($sigmeth) .
"&oauth_timestamp=" . urlencode($now) .
"&oauth_token=" . urlencode($auth->oauth_token) .
"&oauth_version=" . urlencode($av);
$base = "GET&" . urlencode($path) . "&" . urlencode($args);
$sig = base64_encode(hash_hmac($algo, $base,
"{$secret}&{$auth->oauth_token_secret}", true));
$url = $path . "?oauth_signature=" . urlencode($sig) . "&" . $args;
// Create a stream
$opts = array(
"http" => array(
"method" => "GET",
"header" => "Authorization: OAuth " .
"oauth_version=\"{$av}\", " .
"oauth_nonce=\"{$nonce}\", " .
"oauth_timestamp=\"{$now}\", " .
"oauth_consumer_key=\"{$consumer}\", " .
"oauth_token=\"{$auth->oauth_token}\", " .
"oauth_signature_method=\"{$sigmeth}\", " .
"oauth_signature=\"{$sig}\"\r\n"
)
);
$context = stream_context_create($opts);
$out = file_get_contents($path, false, $context);
?>

Categories