roice81
roice81

Reputation: 49

Set Facebook URL to Share with Parameters

Is it possible to crate SHARE link for specific page in my website? For instance:

http://www.MY-SITE.COM/index.php?page=show_book&book_id=$book_id

I tried:

<a title='Share on Facebook'
  href='http://www.facebook.com/sharer.php?u=http://www.MY-SITE.COM/index.php?page=show_book&book_id=$book_id'  
  target='_blank'>
     Share on Facebook
 </a>

but it doesn't get the parameters.

Upvotes: 2

Views: 4230

Answers (5)

PHP Ferrari
PHP Ferrari

Reputation: 15616

replace & with %26 something like

$url = 'http://www.MY-SITE.COM/index.php?page=show_book%26book_id='.$book_id;
<a title="Share on Facebook"
  href="http://www.facebook.com/sharer.php?u=<?=$url?>">Share on Facebook</a>

Upvotes: 0

nullable
nullable

Reputation: 2571

A common approach to this, which will work amongst other providers too (twitter, g+ etc) is to use a url shortening service like http://bit.ly.

Upvotes: 0

kingkode
kingkode

Reputation: 2220

looks like you need to echo your $book_id:

<a title='Share on Facebook'
  href='http://www.facebook.com/sharer.php?u=http://www.MY-SITE.COM/index.php?page=show_book&book_id=<?php echo $book_id ?>'  
  target='_blank'>
     Share on Facebook
 </a>

Upvotes: 0

bbrewer97202
bbrewer97202

Reputation: 187

If the parameters are getting stripped, try url encoding them (rawurlencode() in PHP).

Also make sure your target share page is serving up different open graph meta tags based on the parameters.

Upvotes: 2

yunzen
yunzen

Reputation: 33439

Share button is old. FB recommends to use the like-Button

http://developers.facebook.com/docs/reference/plugins/like/

Upvotes: 1

Related Questions