hello,

i have to share products in facebook from my site.
i used ths code for share.

<a href="http://www.facebook.com/sharer.php?u=http://<?=$_SERVER['HTTP_HOST']?>/blockbuys/details.php?route=product/product&product_id=<?=$fetpro['auto_id']?>&amp;t=<?=$fetpro['productname']?>"><img src="images/facebook.jpg" /></a>

but product image is not displaying in facebbook.
how to do this task?

thnks.

Recommended Answers

All 4 Replies

Inside your php opening and closing tags you need to echo the $_SERVER['HTTP_HOST'] or whatever, you can't just write it the way that you have. Also, you shouldn't use short tags for opening and closing php, use <?php ?> instead.

Inside your php opening and closing tags you need to echo the $_SERVER['HTTP_HOST'] or whatever, you can't just write it the way that you have. Also, you shouldn't use short tags for opening and closing php, use <?php ?> instead.

i just wrote what you said..

<a href="http://www.facebook.com/sharer.php?u=http://<?php echo $_SERVER['HTTP_HOST']?>/blockbuys/details.php?route=product/product&product_id=<?php echo $fetpro['auto_id']?>&amp;t=<?php echo $fetpro['productname']?>"><img src="images/facebook.jpg" /></a>

but in facebook there is displaying hostname insted of productname. and also product image is not displaying automatically..and next total url is not comming just displaying like this.

rahul
http://rahul/blockbuys/details.php?route...

above the url actually displays my product name..but it displaying hostname. and also displaying half url only..i have faced same situation in twitter also.

Don't forget to end your php statements with a semi-colon.

<?php echo $_SERVER['HTTP_HOST']; ?>

I'm not sure if this is your problem though as I thought you would get errors...

k...i was added like this. every thing is working fine.
but product description is not displaying there.
here is my code.

<meta name="title" content="<?=$fetpro['productname']?>" />
<meta name="description" content="Join this bloc to help me get a deal at BlocBuys!"/>
  <link rel="image_src" href="admin/product_images/60x60/<?=$fetpro['product_image']?>"/ >
<a href="http://www.facebook.com/sharer.php?u=http://www.xyz.com/xyz/details.php?pro_id=<?php echo $fetpro['auto_id']?>&t=<?php echo $fetpro['productname']?>"><img src="images/facebook.jpg" /></a>

here in facebook displaying automatically name of the product and image of the product.
but it is not displaying product discription ...i mean content which was in meta tag in my header.
so how to display description of the product direct in content field which is in facebook sharer.php page

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.