Jump to content

Facebook - problem with default image when sharing link using PHP SDK


BagoZonde

Recommended Posts

Hello!

I hope this is the right place to ask.

 

I'm using Facebook PHP SDK (v.3.2.2) to share link on my Facebook's wall.

Everything works fine, I can submit link and message.

 

However there's a problem with image. Sometimes Facebook will find image I've expected but often he's selecting CAPTCHA image (which is located in HTML code at the bottom of page).

 

So, how can I pick up right image for sharing on Facebook wall?

 

When I'm sharing exactly that same links by hand on Facebook's wall - everything works fine, but with SDK it sucks very often.

 

I was trying two things without luck:

 

1. Post picture's filepath (see: PHP example below).

2. By inserting:

<meta property="og:image" content="http://www.absolutepath.to/image.jpg" />

in head section.

 

I can't find solution.

 

This is some parts from my code as it's really not necessary to paste everything as all working well, it's just some image issue.

Of course as post url I'm using /links to share instead of /feed to post. As I believe, this is the only way to create ability to share this post by other people on Facebook. When posting as /feed, no one can share this post.

$configuration['facebook_scope']=>'publish_stream,offline_access,read_stream,manage_pages';
                $post_url = '/'.$Field['FacebookPageID'].'/links'; //post as /links for share

                $facebook = new Facebook($configuration['facebook_app']);

                //the Posting Parameters
                $PostData = array(
                    'message' => $Field['FacebookMessage'],
                    'link' => $Field['FacebookLink'],
                    'picture' => $Field['FacebookPicture'], //I'm not sure it's used for share, I think: it's not
                    'access_token' =>$OurAccessToken,
                );
$result = $facebook->api($post_url, 'post', $PostData);

Please help me as I'm so close to make it real and I hope this post will help other people in future.

 

P.S. I've checked url I want to share on https://developers.facebook.com/tools/debug and there everything looks fine with og:image

Edited by BagoZonde
Link to comment
Share on other sites

I think it could be something with Facebook's cache (I was reading about it few minutes ago) as I tried to share old link (never exposed to Facebook) and it works well! However Facebook Debugger should work that same way but he doesn't and returns everything (as well as proper image) in right way.

 

I'm confused.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.