Coder Social home page Coder Social logo

apitests / block_io-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geopayme/block_io-php

0.0 2.0 0.0 432 KB

The PHP library for Block.io's easy wallet creation, money sending and received API for Dogecoin, Litecoin, and Bitcoin.

PHP 100.00%

block_io-php's Introduction

Block.io PHP

Current Release: 1.0.4

10/08/14: Added 3 of 4 MultiSig example.
09/28/14: Updated for v2 handling.

PHP wrapper for Block.io for use with Dogecoin, Bitcoin, and Litecoin. API key validation on instantiation, simple abstraction layer on top of existing API interfaces, and automatic JSON decoding on response.

Requirements

This library requires the 'mcrypt', 'gmp', and cURL extensions for PHP. To enable these extensions, see:

mCrypt Installation Guide

GMP Installation Guide

cURL Installation Guide

Warning

If you're using Windows, beware that SSL will not function properly, and this library will throw errors.

To fix the SSL issue on Windows, please do the following:

Download http://curl.haxx.se/ca/cacert.pem to a directory of your choice
Make PHP use this file to validate Block.io's SSL certificate by adding this line to your php.ini:
curl.cainfo=c:\path\to\cacert.pem

Usage

First, sign up for an account at Block.io and take note of your API key under Account > Dashboard.

Download and include the block_io.php class:

 require_once 'path/to/block_io.php';

Or preferably install via Composer

 "block_io-php/block_io-php": "1.0.0"

Instantiate the class and set your API key. If the API key is valid the set function will return true otherwise false.

 $apiKey = "YOUR API KEY FOR DOGECOIN, BITCOIN, OR LITECOIN";
 $pin = "YOUR SECRET PIN";
 $version = 2; // the API version to use

 $block_io = new BlockIo($apiKey, $pin, $version);

 echo "Confirmed Balance: " . $block_io->get_balance()->data->available_balance . "\n";

The wrapper abstracts all methods listed at https://block.io/api/php using the same interface names. For example, to get your current account balance:

     $balance = $block_io->get_balance(array('label' => 'default'));
     echo $balance->data->available_balance . "\n";

To make requests that require parameters (eg. an address label or address to withdraw to), pass through each parameter in an associative array. For example, the request below will withdraw 50 DOGE to the wallet you specify in place of WALLET-ADDRESS-HERE:

     $withdraw = $block_io->withdraw(array('amount' => '50.0', 'to_address' => 'WALLET-ADDRESS-HERE'));

Note: This library throws Exceptions when calls fail. Implement try/catch blocks, and retrieve the Exception message to see details.

Please see Block.io PHP Docs for details on available calls.

block_io-php's People

Contributors

doersf avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.