From 05e8e5b9a9f637f6a775c33687fe12ebaf7ae75c Mon Sep 17 00:00:00 2001 From: dongdongqin Date: Tue, 13 Sep 2016 16:24:42 +0800 Subject: [PATCH] adjust api --- README.md | 4 +++- account.config | 3 +++ sample.php | 63 ++++++++++++++++++++++++++++---------------------- 3 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 account.config diff --git a/README.md b/README.md index 7f8afdb..1f5ae89 100644 --- a/README.md +++ b/README.md @@ -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'); ``` @@ -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); diff --git a/account.config b/account.config new file mode 100644 index 0000000..0bdac26 --- /dev/null +++ b/account.config @@ -0,0 +1,3 @@ +609907f8-f293-4165-9764-8c01b92e09a5 +1cac6105-0eb0-401d-a82c-7912290a5f5e + diff --git a/sample.php b/sample.php index 187dc56..4babba3 100644 --- a/sample.php +++ b/sample.php @@ -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 "
"; +$form = ' + + +
'; + +echo $form; + if($_POST) { - echo "
";
-	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 "
"; + echo "
";
+    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 "
"; } -echo "" + ?> \ No newline at end of file