<p>The address validation script is actually from RosettaCode <a href="https://rosettacode.org/wiki/Bitcoin/address_validation#PHP" rel="nofollow noreferrer">https://rosettacode.org/wiki/Bitcoin/address_validation#PHP</a></p>

<p>All you need to do is create the new address and then put the address in a QR Code. You could use the Google Charts API</p>

<pre><code>&lt;?php 
 require_once("block_io.php");

$block_io = new BlockIo($apiKey, $pin, $version);
$createAddress = $block_io-&gt;get_new_address();
$address = $createAddress-&gt;data-&gt;address;
?&gt;

&lt;html&gt;
This is your new address: &lt;br&gt;
&lt;img src="http://chart.googleapis.com/chart?chs=125x125&amp;cht=qr&amp;chl=&lt;?php echo $address; ?&gt;"&gt;
&lt;/html&gt;
</code></pre>

CC BY-SA 3.0
2016-12-08T09:47:27.857Z
Hi Kyle thanks again for the rescue, your scripts works well as usual! I have a question, how do I put the block.io real time notifs? I'm having trouble understanding their docs. lets say I received 30 transactions on block.io, how do I put that in my page? TIA Kyle!
PPY XIII
CC BY-SA 3.0
2016-12-08T06:17:47.677Z
2016-12-08T06:17:47.677Z
m1xolyd1an
<p>Hi guys as the title says. how can I generate a QR code whenever the block_io.php generates a unique address? I seem to have a problem when calling $newAddressInfo or $newAddressInfo->data->address whenever I'm echo-ing it. Please disregard the missing characters as per it's perfectly working.
so this is the whole script.</p>

<p>Bitcoin Address validator from Kyle : <a href="https://www.youtube.com/channel/UC4VfjvgWBVMH1S3Aij-XvRg" rel="nofollow noreferrer">HIS YOUTUBE CHANNEL</a><br>
QR GENERATOR FROM : <a href="https://www.youtube.com/watch?v=sFVcOFmnZ9Y" rel="nofollow noreferrer">TERRAGON</a></p>

<p>I just tweaked kyle's script.</p>

<p><strong>SCRIPT :</strong> </p>

<pre><code>require_once ("block_io.php");


$apiKey = "myAPIkey"; &lt;br&gt;
$version = 2; // API version &lt;br&gt;
$pin = "myPin";&lt;br&gt;
$block_io = new BlockIo($apiKey, $pin, $version);&lt;br&gt;

if(isset($_POST['submit'])){
    $newAddressInfo = $block_io-&gt;get_new_address();
    $address = $_POST['addr'];
    $decoded = decodeBase58($address);

    $d1 = hash("sha256", substr($decoded,0,21), true);
    $d2 = hash("sha256", $d1, true);

    if(substr_compare($decoded, $d2, 21, 4)){
        $message = "Invalid Bitcoin Address";
    } else {
        $message1 = "Valid Address";
        $message2 = "Your Receiving Address : ";
    }
}


function decodeBase58($input) {
    $alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

    $out = array_fill(0, 25, 0);
    for($i=0;$i&lt;strlen($input);$i++){
        if(($p=strpos($alphabet, $input[$i]))===false){
                throw new \Exception("invalid character found");
        }
        $c = $p;
        for ($j = 25; $j--; ) {
                $c += (int)(58 * $out[$j]);
                $out[$j] = (int)($c % 256);
                $c /= 256;
                $c = (int)$c;
        }
        if($c != 0){
            throw new \Exception("address too long");
        }
    }

    $result = "";
    foreach($out as $val){
            $result .= chr($val);
    }

    return $result;
}

&lt;/form method="post"&gt;
    &lt;input style="width: 100%;" name="addr" type="text"&gt;
&lt;center&gt;&lt;input name="submit" type="submit"&gt;&lt;br&gt;


if (isset($message)){ echo $message; } &lt;br&gt;
 if (isset($message2)){ echo " Your Unique Deposit Address: " .$newAddressInfo-&gt;data-&gt;address."&lt;br&gt;"; } &lt;br&gt;
 if (isset($message2)) $str = "Your Receiving Address : ";
 $str ; echo $address = $_POST['addr']; &lt;br&gt;
 if (isset($message2)){ echo img src='qr/qr_img.php?d=$newAddressInfo-&gt;data-&gt;address'&gt; ; } &lt;br&gt;


&lt;/form&gt;
</code></pre>

<api><qrcode>
How to put QR Code whenever I generate a unique address? block.io API
PPY XIII
# How to put QR Code whenever I generate a unique address? block.io API

(Asked by: username_0 on 2016-12-07)

Hi guys as the title says. how can I generate a QR code whenever the block\_io.php generates a unique address? I seem to have a problem when calling $newAddressInfo or $newAddressInfo->data->address whenever I'm echo-ing it. Please disregard the missing characters as per it's perfectly working.
so this is the whole script.

Bitcoin Address validator from Kyle : [HIS YOUTUBE CHANNEL](https://www.youtube.com/channel/UC4VfjvgWBVMH1S3Aij-XvRg)  
QR GENERATOR FROM : [TERRAGON](https://www.youtube.com/watch?v=sFVcOFmnZ9Y)

I just tweaked kyle's script.

**SCRIPT :**

```
require_once ("block_io.php");

$apiKey = "myAPIkey"; <br>
$version = 2; // API version <br>
$pin = "myPin";<br>
$block_io = new BlockIo($apiKey, $pin, $version);<br>

if(isset($_POST['submit'])){
    $newAddressInfo = $block_io->get_new_address();
    $address = $_POST['addr'];
    $decoded = decodeBase58($address);

    $d1 = hash("sha256", substr($decoded,0,21), true);
    $d2 = hash("sha256", $d1, true);

    if(substr_compare($decoded, $d2, 21, 4)){
        $message = "Invalid Bitcoin Address";
    } else {
        $message1 = "Valid Address";
        $message2 = "Your Receiving Address : ";
    }
}

function decodeBase58($input) {
    $alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

    $out = array_fill(0, 25, 0);
    for($i=0;$i<strlen($input);$i++){
        if(($p=strpos($alphabet, $input[$i]))===false){
                throw new \Exception("invalid character found");
        }
        $c = $p;
        for ($j = 25; $j--; ) {
                $c += (int)(58 * $out[$j]);
                $out[$j] = (int)($c % 256);
                $c /= 256;
                $c = (int)$c;
        }
        if($c != 0){
            throw new \Exception("address too long");
        }
    }

    $result = "";
    foreach($out as $val){
            $result .= chr($val);
    }

    return $result;
}

</form method="post">
    <input style="width: 100%;" name="addr" type="text">
<center><input name="submit" type="submit"><br>

if (isset($message)){ echo $message; } <br>
 if (isset($message2)){ echo " Your Unique Deposit Address: " .$newAddressInfo->data->address."<br>"; } <br>
 if (isset($message2)) $str = "Your Receiving Address : ";
 $str ; echo $address = $_POST['addr']; <br>
 if (isset($message2)){ echo img src='qr/qr_img.php?d=$newAddressInfo->data->address'> ; } <br>

</form>

```

**Tags:** api, qrcode


---

## 1 answers

### Answer by username_1 on 2016-12-08. Score: 1 | Accepted answer

The address validation script is actually from RosettaCode <https://rosettacode.org/wiki/Bitcoin/address_validation#PHP>

All you need to do is create the new address and then put the address in a QR Code. You could use the Google Charts API

```
<?php 
 require_once("block_io.php");

$block_io = new BlockIo($apiKey, $pin, $version);
$createAddress = $block_io->get_new_address();
$address = $createAddress->data->address;
?>

<html>
This is your new address: <br>
<img src="http://chart.googleapis.com/chart?chs=125x125&cht=qr&chl=<?php echo $address; ?>">
</html>

```

> **Comments:**
> **username_0**: Hi Kyle thanks again for the rescue, your scripts works well as usual! I have a question, how do I put the block.io real time notifs? I'm having trouble understanding their docs. lets say I received 30 transactions on block.io, how do I put that in my page? TIA Kyle!  

---

