Get started with CoinDaddy Public Server

@jdogresorg

I tried to connect to the public counterparty server - https://coindaddy.io/public-development-servers - with the sample PHP script. Got error:

`Warning: strpos() expects parameter 1 to be string, array given in /home/xcpprjbs/public_html/dex/JsonRPC/src/JsonRPC/Client.php on line 319

Fatal error: Class ‘JsonRPC\AccessDeniedException’ not found in /home/xcpprjbs/public_html/dex/JsonRPC/src/JsonRPC/Client.php on line 320`

I used this JsonRPC library : https://github.com/fguillot/JsonRPC

I’m not that familiar with PHP. Should the script be installed? I only uploaded the folder.

After adding require 'JsonRPC/src/JsonRPC/AccessDeniedException.php'; it prints this error:

`Warning: strpos() expects parameter 1 to be string, array given in /home/xcpprjbs/public_html/dex/JsonRPC/src/JsonRPC/Client.php on line 319

Fatal error: Uncaught exception ‘JsonRPC\AccessDeniedException’ with message ‘Response: Array’ in /home/xcpprjbs/public_html/dex/JsonRPC/src/JsonRPC/Client.php:320 Stack trace: #0 /home/xcpprjbs/public_html/dex/JsonRPC/src/JsonRPC/Client.php(350): JsonRPC\Client->handleHttpErrors(Array) #1 /home/xcpprjbs/public_html/dex/JsonRPC/src/JsonRPC/Client.php(211): JsonRPC\Client->doRequest(Array) #2 /home/xcpprjbs/public_html/dex/index.php(12): JsonRPC\Client->execute(‘get_running_inf…’) #3 {main} thrown in /home/xcpprjbs/public_html/dex/JsonRPC/src/JsonRPC/Client.php on line 320`

Use the library here http://jsonrpcphp.org/

1 Like

Thanks loon… I was just about to point him to jsonrpcphp.org… but looks like your on top of it :wink:

Good news! Did some more testing and CoinDaddy’s example script works from my local computer (I use XAMPP to run PHP).

When running on the web server I still get error
Fatal error: Uncaught exception 'JsonRPC\AccessDeniedException'
It may be that CoinDaddy blocks the web host I’m using (namecehap)?

I used https://github.com/fguillot/JsonRPC but will try http://jsonrpcphp.org whenever that’s needed. Thanks for the tip!

1 Like

Here’s the example code with pre tags and print_r for more human friendly output:

<pre lang="php"><?php
require 'JsonRPC/src/JsonRPC/Client.php'; //https://github.com/fguillot/JsonRPC
use JsonRPC\Client;
$client = new Client('http://public.coindaddy.io:4000/api/');
$client->authentication('rpc', '1234');
</pre>
`print("<pre>");`
<pre lang="php">
$result = $client->execute('get_balances', array('filters' => array('field' => 'address', 'op' => '==', 'value' => '1NFeBp9s5aQ1iZ26uWyiK2AYUXHxs7bFmB')));
print("get_balances result:\n");
print_r($result);

$result2 = $client->execute('get_running_info');
print("get_running_info result:\n");
print_r($result2);
</pre>
`print("</pre>");`
<pre lang="php">
?></pre>