Skip to content

Commit bebb684

Browse files
author
Antoine Le Calvez
committed
Made service URL required
1 parent 347571e commit bebb684

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ Download the source or clone the repository. This php library works with the [Co
1313
$ composer install
1414
```
1515

16-
This will create the `/vendor` folder in the repository root. In the php source, simply:
16+
This will create the `/vendor` folder in the repository root.
17+
18+
In order to use Wallet and CreateWallet functionnality, you must provide an URL to an instance of [service-my-wallet-v3](https://github.com/blockchain/service-my-wallet-v3) as first parameter to \Blockchain\Blockchain.
19+
If you don't use these functionnalities, this parameter can be set to null.
20+
21+
In the php source, simply:
1722
```php
1823
// Include the autoload.php from its vendor directory
1924
require 'vendor/autoload.php'
2025

2126
// Create the base Blockchain class instance
22-
$Blockchain = new \Blockchain\Blockchain();
27+
$Blockchain = new \Blockchain\Blockchain('http://localhost:3000');
2328
```
2429

2530
All functionality is provided through the `Blockchain` object.
@@ -29,7 +34,7 @@ All functionality is provided through the `Blockchain` object.
2934
The [official documentation](https://blockchain.info/api) lists API call limits, which may be bypassed with an API code. If you use a code, enter it when you create the `Blockchain` object:
3035

3136
```php
32-
$Blockchain = new \Blockchain\Blockchain($my_api_code);
37+
$Blockchain = new \Blockchain\Blockchain('http://localhost:3000', $my_api_code);
3338
```
3439

3540
If you need an API code, you may request one [here](https://blockchain.info/api/api_create_code).

src/Blockchain.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@
4343

4444
class Blockchain {
4545
const URL = 'https://blockchain.info/';
46-
const SERVICE_URL = 'http://localhost';
4746

4847
private $ch;
4948
private $api_code = null;
5049

5150
const DEBUG = true;
5251
public $log = Array();
5352

54-
public function __construct($api_code=null) {
53+
public function __construct($service_url, $api_code=null) {
54+
$this->service_url = $service_url;
55+
5556
if(!is_null($api_code)) {
5657
$this->api_code = $api_code;
5758
}
@@ -86,7 +87,7 @@ public function post($resource, $data=null) {
8687
$url = URL;
8788

8889
if (($resource == "api/v2/create") || (substr($resource, 0, 8) === "merchant")) {
89-
$url = SERVICE_URL;
90+
$url = $this->service_url;
9091
}
9192

9293
curl_setopt($this->ch, CURLOPT_URL, $url.$resource);

0 commit comments

Comments
 (0)