Title: Why this PHP code is not posting BTC price in USD on 29-08-2019? Post by: CounterEntropy on August 29, 2022, 05:23:09 PM Neither this...
Code: $ch = curl_init(); Nor this... Code: ini_set('max_execution_time', 300); What am I doing wrong? p.s. I could not find a better place to ask this question on BitcoinTalk. So, asking it here. If mods think, it does not fit here, feel free to move. Title: Re: Why this PHP code is not posting BTC price in USD on 29-08-2019? Post by: BitMaxz on August 29, 2022, 11:56:53 PM I think this is not the right place to talk about this I think the development and technical or project development section is the right section for this. I'll ask mods to move this thread
Anyway, about your PHP issue have you read the Coingecko API documentation? I think you need to try to ping your API status through this command below to check if your API is online Code: $data = $client->ping(); Also, I would like to ask if you already created an account in Coingecko is it a free one that has limited API request daily? I think you can try the Coingecko PHP code from this link below it might help how to install/use those codes properly. - https://github.com/codenix-sv/coingecko-api Title: Re: Why this PHP code is not posting BTC price in USD on 29-08-2019? Post by: TryNinja on August 30, 2022, 01:11:04 AM What do you get when you visit the page? Both of your codes are working fine on my end. :P
It returns 9753.4870488971, which matches what the API endpoint (https://api.coingecko.com/api/v3/coins/bitcoin/history?date=29-08-2019&localization=false) returns (with the last digit being rounded). Title: Re: Why this PHP code is not posting BTC price in USD on 29-08-2019? Post by: edgycorner on August 30, 2022, 04:47:21 AM What do you get when you visit the page? Both of your codes are working fine on my end. :P It returns 9753.4870488971, which matches what the API endpoint (https://api.coingecko.com/api/v3/coins/bitcoin/history?date=29-08-2019&localization=false) returns (with the last digit being rounded). Yup, both of his codes are working fine. I checked it as well. Something similar happened to me once, there was nothing wrong with code and still it wasn't working. Turned out that my server's IP address was being blocked by Cloudflare. Maybe something similar is happening to OP. Try making a simple curl request to the api, and see what response you get. Title: Re: Why this PHP code is not posting BTC price in USD on 29-08-2019? Post by: NotATether on August 30, 2022, 05:50:14 AM You know, it would really make this a lot simpler if you post the CURL error code or server response you got here.
What do you get when you visit the page? Both of your codes are working fine on my end. :P It returns 9753.4870488971, which matches what the API endpoint (https://api.coingecko.com/api/v3/coins/bitcoin/history?date=29-08-2019&localization=false) returns (with the last digit being rounded). Yup, both of his codes are working fine. I checked it as well. Something similar happened to me once, there was nothing wrong with code and still it wasn't working. Turned out that my server's IP address was being blocked by Cloudflare. Maybe something similar is happening to OP. Try making a simple curl request to the api, and see what response you get. Alternatively, try connecting with a proxy (spin up a temporary VPS for at BitVPS for just $1 and install Squid on it, and try connecting with that). Title: Re: Why this PHP code is not posting BTC price in USD on 29-08-2019? Post by: decodx on August 30, 2022, 08:53:13 PM CounterEntropy, as others have already said, your code works fine. It is possible that you are blocked on the server side. Try to open the url of the API endpoint in your browser. Do you get a proper response? Try changing your IP address if you can.
Title: Re: Why this PHP code is not posting BTC price in USD on 29-08-2019? Post by: serhack on September 10, 2022, 09:09:45 AM As all of these users said, coingecko might have rate-limited you or your IP was blocked. If you're under VPN, there's high chance that Coingecko rate-limited/banned you from the service.
|