I am using an API I found online for querying a remote Grin daemon using curl. I am trying to convert the bash curl request below into PHP, but I am not sure how I pass the .api_secret using PHP's curl library.
Bash
$ curl -0 -XPOST -u grin:`cat ~/.grin/floo/.api_secret` --data '{"jsonrpc":"2.0","method":"retrieve_summary_info","params":[true, 10],"id":1}' http://127.0.0.1:13420/v2/owner
The main part of this command I am confused about is as follows:
grin:`cat ~/.grin/floo/.api_secret`
How do I convert the command above into PHP format? This is what I have so far:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:13420/v2/owner');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"jsonrpc\":\"2.0\",\"method\":\"retrieve_summary_info\",\"params\":[true, 10],\"id\":1}");
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
return $result;
curl_close($ch);
file_get_contentsin it's place - php.net/manual/en/function.file-get-contents.php