api v1 getting images

A place for developers to advertise their TheTVDB.com enabled app and get help from other developers with the API.
Post Reply
Posts: 2
Joined: Sun Sep 17, 2017 11:10 am

Sun Sep 17, 2017 11:17 am


Starting a few days ago, it seems I'm not able to download any images. All images I'm attempting to get are 0 size at the end.
For simplicity, let's take this short php code which has worked for a very long time now:

Code: Select all

$s= "1888.jpg";
$u= "http://thetvdb.com/banners/actors/1888.jpg";
$chposter = curl_init($u);
$pName = $s;
$fpposter = fopen($pName, 'wb') or die;
if(!$fpposter) die("Can't open image: ../img/".$pName);
curl_setopt($chposter, CURLOPT_FILE, $fpposter);
curl_setopt($chposter, CURLOPT_HEADER, 0);
curl_setopt($chposter, CURLOPT_VERBOSE,1);
curl_setopt($chposter, CURLOPT_STDERR,fopen('php://stderr','w'));
Curl verbose says:

Code: Select all

*   Trying
* Connected to thetvdb.com ( port 80 (#0)
> GET /banners/actors/1888.jpg HTTP/1.1
Host: thetvdb.com
Accept: */*

< HTTP/1.1 301 Moved Permanently
< Date: Sun, 17 Sep 2017 18:01:56 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: max-age=3600
< Expires: Sun, 17 Sep 2017 19:01:56 GMT
< Location: https://www.thetvdb.com/banners/actors/1888.jpg
< Server: cloudflare-nginx
< CF-RAY: 39fdf93d42123fcb-YUL
* Connection #0 to host thetvdb.com left intact
If I wget the URL in question I have the image properly downloaded, but with curl it ends up at 0 size.

Any suggestions please?

- hazy
Posts: 2
Joined: Sun Sep 17, 2017 11:10 am

Sun Sep 17, 2017 11:23 am

And I figured it out 2 mins after I posted this as I was re-reading my own post...
If anyone is in the same boat as me, it's because of the http/s.

Solution is either replace http with https or adding

Code: Select all

curl_setopt($chposter, CURLOPT_FOLLOWLOCATION, 1);
Post Reply