By limcheapheng
I using curl php to get data from another server. When I test on localhost it working fine.
These are my testing code
<?php
$data = file_get_contents_curl('http://marketplace.envato.com/api/edge/new-files:graphicriver,web-elements.json');
function file_get_contents_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
I got this error when using on vps server
["url"]=> string(79) "http://marketplace.envato.com/api/edge/new-files:graphicriver,web-elements.json" ["content_type"]=> string(9) "text/html" ["http_code"]=> int(403) ["header_size"]=> int(148) ["request_size"]=> int(231) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.076722) ["namelookup_time"]=> float(0.038561) ["connect_time"]=> float(0.045397) ["pretransfer_time"]=> float(0.045438) ["size_upload"]=> float(0) ["size_download"]=> float(564) ["speed_download"]=> float(7351) ["speed_upload"]=> float(0) ["download_content_length"]=> float(564) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.07661) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(12) "72.52.12.238" ["certinfo"]=> array(0) { } ["primary_port"]=> int(80) ["local_ip"]=> string(14) "104.131.221.69" ["local_port"]=> int(34671)
My server using Ubuntu php 5.5
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
If it’s working from your local machine, it could be the case that your VPS IP address was blacklisted in some way in that API. A good idea is to create a new droplet and test from it.
This comment has been deleted
May be because graphicriver is requiring authentification? 403 -> forbidden
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.