Facebook – fbml_refreshImgSrc

Date October 18, 2007 @ 2:08 pm in Open Source, PHP

Maybe its just a temporary thing, but lately the Facebook server has had major issues with caching images.  If you are unaware, all images that are placed within a users profile page get scraped by Facebook and served up from their own internal servers.  If for some unforeseen reason there scraper fails your image gets replaced with an invisible pixel spacer gif.  To force the cache to update you have to manually call the fbml_refreshImgSrc method on their REST server.  The easiest way to accomplish this is to create a dedicated page that uses an infinite session.  Here is the PHP page I created to update the images as necessary.

1
2
3
4
5
6
$myClass = new my_class($api_key, $secret); 
//this sets a user and session 
$myClass ->facebook->set_user($global_user, $global_session); 
if(isset($_GET['url'])) { 
  echo '' . $myClass ->facebook->api_client->fbml_refreshImgSrc($_GET['url']) .''; 
}

/p>

3 Responses to “Facebook – fbml_refreshImgSrc”

  1. Nadim said:

    Hey,
    I’m trying to get this to work but I’m a bit of a beginner here. Could you walk me through the process?

    Thanks.

  2. Nadim said:

    I’m getting a

    Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or ‘$’ in /home/facebook_app/update.php on line 2

    any ideas?

  3. Brian G said:

    If you are getting an error it is most likely because you are not calling the Facebook Client. Example:
    $facebook = new Facebook($api_key, $secret);

    Hope this helps.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">