khashnan / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

facebook pictures error #238

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I try to get timthumb to resize main images of facebook albums.

A TimThumb error has occured

The following error(s) occured:
An error occured fetching image.

Query String : 
src=https://graph.facebook.com/188345861231050/picture&h=150&w=150
TimThumb version : 2.7

Is there any way to make it work?

Original issue reported on code.google.com by p.ba...@eminus.pl on 18 Aug 2011 at 10:08

GoogleCodeExporter commented 8 years ago
You must configure TimThumb :

define ('ALLOW_EXTERNAL', TRUE);

and

$ALLOWED_SITES = array (
    'facebook.com'
);

Original comment by neopheus on 18 Aug 2011 at 10:20

GoogleCodeExporter commented 8 years ago
now i get 'The remote file is not a valid image.'

Original comment by p.ba...@eminus.pl on 18 Aug 2011 at 10:31

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
i have exactly the same problem.
timthumb works fine, but not with facebook graph.

what can it be?
heeeeelp!?

Original comment by gpin...@gmail.com on 21 Oct 2011 at 6:21

GoogleCodeExporter commented 8 years ago
URL getting error sample:
http://republicarayada.com.mx/timthumb.php?src=https://graph.facebook.com/100000
043114207/picture?type=normal&h=104&w=83&zc=1

please!

Original comment by gpin...@gmail.com on 21 Oct 2011 at 6:30

GoogleCodeExporter commented 8 years ago
i used a function that gets a real url for me and then timthumb on realurl

    public function getRealUrl($photoLink) {            
        curl_setopt($this->curl, CURLOPT_HTTPHEADER, $this->header);
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, false);
        curl_setopt($this->curl, CURLOPT_HEADER, false);
        curl_setopt($this->curl, CURLOPT_USERAGENT, $this->useragent);
        curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 10);
        curl_setopt($this->curl, CURLOPT_TIMEOUT, 15);
        curl_setopt($this->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($this->curl, CURLOPT_URL, $photoLink);
        //this assumes your code is into a class method, and uses $this->readHeader as the callback //function
        curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(&$this,'readHeader'));
        $response = curl_exec($this->curl);
        if(!curl_errno($this->curl)) {
            $info = curl_getinfo($this->curl);
//            var_dump($info);
             if($info["http_code"] == 302) {
                 $headers = $this->getHeaders();
                 if(isset($headers['fileUrl'])) {
                     return $headers['fileUrl'];
                 }
             }
        }
        return false;
    }

Original comment by p.ba...@eminus.pl on 24 Oct 2011 at 7:14

GoogleCodeExporter commented 8 years ago
Facebook defaults to an HTTPS protocol. Try changing it to HTTP and it should 
work. That said, I'm here because of the same issue and there's no changing how 
Facebook delivers the URL.

I'll try that function though.

Original comment by patrickw...@gmail.com on 3 Apr 2012 at 12:20

GoogleCodeExporter commented 8 years ago
The comment in point 6 is the best solution for this

Original comment by BinaryMoon on 27 Sep 2013 at 9:06