I'm trying to extract the bitcoin address from the blockchain. To be more specific if you go to this link https://blockchain.info/btc/block/1 you would see that the bitcoin address on that block is "12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"
What is the best way to extract that details using PHP/Json ?
take a look at blockchain.com/api/blockchain_api
you got everything there.
blockchain.info has an API to get block details.
blockchain.info API
Using https://blockchain.info/block-height/$block_height endpoint, you can pass $block_height as block number that you need.
Then by simple script like below, you can extract the addresses.
<?php
$blockTxs = getBlockTxs(1);
foreach ($blockTxs as $tx) {
foreach ($tx->out as $out)
{
var_dump($out->addr);
}
}
function getBlockTxs($height) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://blockchain.info/block-height/' . $height,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
return (json_decode($response))->blocks[0]->tx;
}
Related
THE FOLLOWING CODE IS RUNNING SMOOTHLY IN MY LOCALHOST. BUT WHEN I UPLOAD THIS FILE IN WEBSERVER[HOSTINGER], IT IS NOT RUNNING.
$partmsg="https://wapush.in/api/send.php?number=";
$partmsg.=$mobno;
$partmsg.="&type=text&message=Dear Admin User $adminname Your Current Password is ";
$partmsg.=$pwd;
$partmsg.=" - GSFCS&instance_id=63D79C168ACAF&access_token=134ac4a6ec1c01c6825b67ddeba70fa8";
$data = [
'collection' => 'RapidAPI'
];
$curl = curl_init($partmsg);
$response = curl_exec($curl);
echo "<script>alert('Your Password is Send to your Registered Mobile Number.');</script>";
IS THERE ANY OTHER WAY TO EXECUTE THE $URL OTHER THAN RapidAPI that I used.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://wapush.in/api/send.php?number=91<10_digit_no>&type=text&message=Dear%20Admin%20User%20$adminname%20Your%20Current%20Password%20is&instance_id=<your_instance_id>&access_token=<your_access_token>',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Try this code. I have tested it. its works with the credentials that you shared. Please don't share your credentials as I see it isfrom gun sheel factory. Remove them immediately
Upvote and accept this as a answer
I am trying to get the JSON data from a Website called
"https://thesimpsonsquoteapi.glitch.me/"
It has some sort of protection and take a while to open.
The Problem. After the site is loaded, you get access to some API calls like
"https://thesimpsonsquoteapi.glitch.me/quotes"
If I try it in Postman, I get back the right JSON response also if I open it up in the browser.
But if I try the to load the Data via curl in PHP i get the html code back from the first protection side. What can I do to get the JSON like in Postman.
$curl = curl_init();
$url = 'https://thesimpsonsquoteapi.glitch.me/quotes?count=1';
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
thx for any help
I want to show my data on my CRM using PHP with curl and also using API.
If there is any other method. You can kindly show it to me
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://b.maxmind.ma/api/leads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authtoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyfdfdiOjE1ODEwODk2MjJ9.Selc36cmT3XyXH6cGdJ3SN-332kx7"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
the response show : error code: 1020
I think the problem is that the website you are trying to request is protected by Cloudflare.
When i try by the postman , this is the header response a get :
The error code 1020 you got is from cloudflare .
First, you can try using this solution that bypasses the Cloudflare problem
KyranRana/cloudflare-bypass
If not working, in this case, you must contact the site owner to remove the block (more here)
I am new to API's so please be easy on me! My school has a ooen data platform API for anyone to use. So, I decided to get a user & key in order to test stuff out. The following code snippet is my script in order to print out the details of a course.
<?php
$APIUSER = “***”; //user value from your application
$APIKEY = “***”; //Api key value from your application
$url = "https://opendata.concordia.ca/API/v1/course/description/filter/000106";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_HEADER => 0,
CURLOPT_USERPWD => $APIUSER . ":" . $APIKEY
));
$response = curl_exec($curl);
print($response);
?>
I tested my API user & API key on the $url page and it worked. Unfortunately, when I run the script on a local server, there is nothing printing. Am I missing something?
I have been working on some code to automate an update to a specific task in AtTask using the API. I am finding some problems using PHP's CURL request for a PUT command. Here is a copy of the code:
$updateURL = "https://[COMPANYURL].attask-ondemand.com/attask/api/v4.0/task?updates={'ID':'TASKID','name':'Ok. Here we go again','commitDate':'2015-10-27T17:30'}";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $updateURL,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => array(
"sessionid: " . $this->sessionId
),
));
$attask_update_json = curl_exec($curl);
The code executes with out any errors being reported, but the return response is blank. I have verified my URL using postman and it processes correctly, but I can not get the code to process in PHP. Any help would be appreciated.