Facebook PHP API: How To Fix Link Image Not Showing

Facebook PHP API: How To Fix Link Image Not Showing

Many people use social media automation to make their lives a little easier and to free up time to take care of other things. Social platforms offer a way to post using API’s, but there are also services that can do it for you.

I was originally using dlvrit to automatically post to UsedSoloDresses.com’s Facebook & Twitter. But a situation arose and it became unreliable. 5 days passed and the service failed to post items from the sites RSS feed.

What made the situation worse, was that dlvrit hadn’t been keeping its users updated as to what was happening. Which was unacceptable. I knew how to code, so figured I’d just do it myself!

I created a “queue” which filled every hour if posts were found. Then every 30 minutes if a post was ready it would post to the Facebook page.

Link Images Were Missing

The script was working perfectly (saving the site €10 per month)!!!! But the problem was that the links being shared were missing the share image. The Open graph image tag was on the page, but it wasn’t being shown.

Facebook Link Images Missing
Facebook Link Images Missing

The API Fix

I discovered that I needed to pre-fetch the page before trying to post the link. Up until this point I was having to manually refresh the share attachments, which defeated the purpose of automation.

I was using the PHP API and so used to following cURL code to scrape the page before posting the link:

$access_token="APP_ID|APP_SECRET"; //replace with your app details
$params = array("id"=>"LINK_URL","scrape"=>"true","access_token"=>$access_token);
$ch = curl_init("https://graph.facebook.com");
curl_setopt_array($ch, array(
$result = curl_exec($ch);

After adding this BEFORE the API tried to post the link, the issue was fixed and the images started showing without having to manually refresh the share attachments.

If anyone is using the Facebook PHP Graph API to post and is having this issue, hopefully it helps you!