Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Firstly, download the library via:
git clone https://github.com/BTCChina/btcchina-api-php
```

Then, add the following line to your project:
Then, add the following line to your project(please see the example in sample.php of btcchina-api-php project):
```php
require_once('BTCChinaLibrary.php');
```
Expand All @@ -19,6 +19,8 @@ require_once('BTCChinaLibrary.php');
Create Trade API keys at https://vip.btcchina.com/account/apikeys, and set proper permissions as indicated.

Spawn BTCChinaAPI instance with access key and secret key mentioned above. Notice that these keys cannot be modified later.
please create a file called account.config which should contains your apikeys (please see the example in btcchina-api-php project).
The method below needs those parameters.

```php
$btcAPI = new BTCChinaAPI(access_key, secret_key);
Expand Down
3 changes: 3 additions & 0 deletions account.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
609907f8-f293-4165-9764-8c01b92e09a5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't put your api key here. It's very dangerous

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that, I use the real data! thank you for reminding me

1cac6105-0eb0-401d-a82c-7912290a5f5e

63 changes: 35 additions & 28 deletions sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,42 @@
// You can hard code the key[0],key[1] here for testing.
$keys = file(dirname(__FILE__) . '/account.config', FILE_IGNORE_NEW_LINES);

echo "<html><body><form action=\"\" method=\"post\"><input type=text name=func /><input type=submit value=submit />";
$form = '<form action="" method="post">
<input type="text" name="func" value="">
<input type="submit" name="submit" value="submit">
</form>';

echo $form;

if($_POST)
{
echo "<br /><pre>";
try
{
$testAPI = new BTCChinaAPI($keys[0], $keys[1]);
// testAPI can be used directly.
// Here we use eval to call the method on UI.
eval("\$res=\$testAPI->".$_POST['func']);
echo htmlspecialchars(var_dump($res));
}
catch(JsonRequestException $e)
{
echo var_dump($e->getMessage() . $e->getMethod() . $e->getErrorCode());
}
catch(ContentException $e)
{
echo var_dump($e->getMessage() . $e->getMethod() . $e->getErrorCode());
}
catch(ConnectionException $e)
{
echo var_dump($e->getMessage() . $e->getMethod() . $e->getErrorCode());
}
finally
{
unset($testAPI);
}
echo "</pre>";
echo "<br /><pre>";
try
{
$testAPI = new BTCChinaAPI($keys[0], $keys[1]);
// testAPI can be used directly.
// Here we use eval to call the method on UI.
eval("\$res=\$testAPI->{$_POST['func']};");

echo htmlspecialchars(var_dump($res));
}
catch(JsonRequestException $e)
{
echo var_dump($e->getMessage() . $e->getMethod() . $e->getErrorCode());
}
catch(ContentException $e)
{
echo var_dump($e->getMessage() . $e->getMethod() . $e->getErrorCode());
}
catch(ConnectionException $e)
{
echo var_dump($e->getMessage() . $e->getMethod() . $e->getErrorCode());
}
finally
{
unset($testAPI);
}
echo "</pre>";
}
echo "</form></body></html>"

?>