Bitcoin Forum
June 06, 2024, 07:21:40 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoin api problem  (Read 830 times)
addy boy (OP)
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
October 01, 2015, 12:07:23 AM
 #1

hey friends i am trying to build a site with the bitcoin features and some of my friends suggested about the blockchain.info api to use it in the php. but after trying many things like watching tutorials from youtube or Following information from the blockchain site i am not able to make anything till now. please anyone show / make a new bitcoin address generating page so i can see where i am doing wrong or missing the peramiters or whatever mistakes i am doing
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
October 01, 2015, 12:23:49 AM
 #2

Give us the code that you are using with sensitive info (Passwords, GUID) removed. I can try and fix it if so, or remake it for you.
addy boy (OP)
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
October 01, 2015, 05:11:24 AM
 #3

Give us the code that you are using with sensitive info (Passwords, GUID) removed. I can try and fix it if so, or remake it for you.
Code:
 <?php
$ID 
"";
$PW "";

$newAddy json_decode(file_get_contents("https://blockchain.info/merchant/$ID/NEW_address?password=$PW"), true);

$parseAddy $newAddy[address];

echo 
$parseAddy;

?>

this is the code i am using let me know where i am making mistake or please make one for me so i can research upon it and can resolve my problems
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
October 01, 2015, 11:31:39 AM
 #4

I can't see any specific problem with your code, though I don't much understand why you are using associative arrays rather than a normal object. I cannot check the syntax of the URL right now, though will try to be sure that's correct when I get home.

What sort of an error do you get? A PHP error or an error returned in the JSON object from Blockchain?
addy boy (OP)
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
October 02, 2015, 03:14:23 AM
 #5

I can't see any specific problem with your code, though I don't much understand why you are using associative arrays rather than a normal object. I cannot check the syntax of the URL right now, though will try to be sure that's correct when I get home.

What sort of an error do you get? A PHP error or an error returned in the JSON object from Blockchain?
when i am running it. it is not showing anything i think this is the blockchain api access problem but i have tryed to white list my ip but still it is not working.and btw what do you mean by using arrays rather than a normal object?
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
October 02, 2015, 09:38:54 AM
 #6

when i am running it. it is not showing anything i think this is the blockchain api access problem but i have tryed to white list my ip but still it is not working.
Have you tried returning the error variable from the JSON output? Try something like this:
Code:
if($newAddy['error']){
     die($newAddy['error'];
}
If the address isn't properly generated, the only thing that will be returned is the error in the JSON.

and btw what do you mean by using arrays rather than a normal object?
Usually when I use json_decode(); I do not use the true at the end of it. It is personal preference if you do or not, as it just returns the data in a different way.

For example, if you use code like this:
Code:
$string = json_decode($JSON, true);
You get the individual variables using things like this:
Code:
$string['object'];

However, if you use it like this:
Code:
$string = json_decode($JSON);
You can get the individual variables using this:
Code:
$string->object;

It just depends what you're used to and how you code.
DevSoft
Sr. Member
****
Offline Offline

Activity: 357
Merit: 250


View Profile
October 02, 2015, 03:14:27 PM
 #7

hey friends i am trying to build a site with the bitcoin features and some of my friends suggested about the blockchain.info api to use it in the php. but after trying many things like watching tutorials from youtube or Following information from the blockchain site i am not able to make anything till now. please anyone show / make a new bitcoin address generating page so i can see where i am doing wrong or missing the peramiters or whatever mistakes i am doing

Code:
			$invoice_id         = ''; // You can use any method you like to generate an unique ID for the generated wallet
$secret             = "98nb987fg0b0e2";
$my_bitcoin_address = "WALLET_ADDRESS_WHERE_TO_FORWARD_BTC_FROM_GENERATED_WALLETS";
$my_callback_url    = 'http://domain.com/callback.php?invoice_id=' .$invoice_id. '&secret='.$secret;
$root_url           = 'https://blockchain.info/api/receive';
$parameters         = 'method=create&address=' . $my_bitcoin_address .'&callback='. urlencode($my_callback_url);

$response    = file_get_contents($root_url . '?' . $parameters);
$object      = json_decode($response);

$object->input_address; // This is the Newly Generated Wallet!

This is working example, tested.
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
October 02, 2015, 05:47:34 PM
 #8

snip

This is working example, tested.
By the use of /merchant/ in the URL call of the API, it looks like he is trying to use the MyWallet API, not the Recieve Payments that you have listed. I doubt that this example is very helpful, especially since that code sample is on the API documentation already.
DevSoft
Sr. Member
****
Offline Offline

Activity: 357
Merit: 250


View Profile
October 02, 2015, 05:53:16 PM
 #9

snip

This is working example, tested.
By the use of /merchant/ in the URL call of the API, it looks like he is trying to use the MyWallet API, not the Recieve Payments that you have listed. I doubt that this example is very helpful, especially since that code sample is on the API documentation already.

Well, its pretty hard to determine what exactly the OP is asking from us. A code sample from hes side would help a lot. Or atleast more detailed info. Just trying to help here.
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
October 02, 2015, 05:59:37 PM
 #10

A code sample from hes side would help a lot.
Code:
<?php
$ID 
"";
$PW "";

$newAddy json_decode(file_get_contents("https://blockchain.info/merchant/$ID/NEW_address?password=$PW"), true);

$parseAddy $newAddy[address];

echo 
$parseAddy;

?>

This is pretty much all that the OP could give us. His PHP syntax appears to be correct, so I believe that it is some kind of problem with the URL he is inputting.

OP, have you tried using the urlencode(); function on your password? I recall when I was using the API and it was bringing back errors it was due to the characters in my password. Using URL encode makes these characters into something that does not affect the URL, but still gives the desired output. Something like this could do the trick:
Code:
$newAddy = json_decode(file_get_contents("https://blockchain.info/merchant/$ID/NEW_address?password=" . urlencode($PW)), true);
addy boy (OP)
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
October 03, 2015, 02:28:19 AM
 #11

not improvin.g a bit. guys can anyone just make a small webpage with bitcoinaddress generator coding and pack it in a zip file and give me.I will simply study your code and try to improve my skills
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
October 03, 2015, 06:14:58 PM
 #12

not improvin.g a bit. guys can anyone just make a small webpage with bitcoinaddress generator coding and pack it in a zip file and give me.I will simply study your code and try to improve my skills
Your coding isn't wrong as far as I can see. That is how I call the API on my page.

Try using this:
Code:
echo file_get_contents("https://blockchain.info/merchant/$ID/NEW_address?password=" . urlencode($PW));
And seeing what it returns.
addy boy (OP)
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
October 04, 2015, 05:19:09 PM
 #13

not improvin.g a bit. guys can anyone just make a small webpage with bitcoinaddress generator coding and pack it in a zip file and give me.I will simply study your code and try to improve my skills
Your coding isn't wrong as far as I can see. That is how I call the API on my page.

Try using this:
Code:
echo file_get_contents("https://blockchain.info/merchant/$ID/NEW_address?password=" . urlencode($PW));
And seeing what it returns.
Code:
 Error 1006 Ray ID: 23028909df0f04fb • 2015-10-04
17:16:34 UTC
Access denied
What happened?
The owner of this website (blockchain.info) has banned
your IP address (31.170.160.75).
CloudFlare Ray ID: 23028909df0f04fb • Your IP:
31.170.160.75 • Performance & security by CloudFlare
thank you for helping me
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
October 04, 2015, 05:40:53 PM
 #14

Alright, what is happening here is that Blockchain has blocked the IP of your hosting provider. I'm unsure how big of a deal this is, but you will have to contact BlockChain Support to get it sorted.

Good luck with your site!
addy boy (OP)
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
October 07, 2015, 03:30:31 AM
 #15

anyone here to help me with the codes . blockchain has unband me but the outputs are showing {"error":"Unknown method"} can anyone please solve this problem btw did anyone got this type of problem or i am the only one
avatar_kiyoshi
Legendary
*
Offline Offline

Activity: 1106
Merit: 1000



View Profile
October 07, 2015, 08:37:32 AM
 #16

anyone here to help me with the codes . blockchain has unband me but the outputs are showing {"error":"Unknown method"} can anyone please solve this problem btw did anyone got this type of problem or i am the only one

There are some site which you can use their api:
https://bitcointalk.org/index.php?topic=1201176.msg12616115#msg12616115

Blockchain.info recently have a lot problem.
addy boy (OP)
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
October 09, 2015, 03:35:33 PM
 #17

anyone here to help me with the codes . blockchain has unband me but the outputs are showing {"error":"Unknown method"} can anyone please solve this problem btw did anyone got this type of problem or i am the only one

There are some site which you can use their api:
https://bitcointalk.org/index.php?topic=1201176.msg12616115#msg12616115

Blockchain.info recently have a lot problem.
well i have already seen that thread too but anyways thank you for the suggestion
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!