-1

I do not know any PHP but I'm trying to make a page to just echo a result which I can then use as a conky config.

This is what I have tried

<?php  
$content=file_get_contents("https://btc-e.com/api/2/ltc_usd/ticker");
$data=json_decode($content);

echo "Current Price: $";
echo $data->ticker->avg;;
?>

But I just get "Current Price: $" without the actual price.

Any help is appreciated, thanks!

1 Answers1

2

First of all, I am assuming you're new to PHP. Welcome. In the future, you should perform the following steps before you even start asking for help.

  1. Enable PHP error messages
  2. Look at the error messages if any
  3. Dump the variable(s) that aren't behaving as expected
  4. You'll probably have your answer by now
  5. If not, then ask for help

In your case it's most likely because you have the PHP setting allow_url_fopen set to Off. Set it to On in your php.ini config file.

Community
  • 1
  • 1
Populus
  • 7,470
  • 3
  • 38
  • 54
  • Hi thanks for this, I was just doing it all from a text editor then ftping it to my test site, so I dont even have a php.ini maybe this is my issue.. Thanks – user3627450 Sep 09 '14 at 22:03
  • 1
    If you're using shared hosting, you're out of luck. You'll need to fetch the content using cURL instead http://stackoverflow.com/questions/21642604/fetching-url-contents-using-php-and-curl – Populus Sep 09 '14 at 22:08