kamesh kamesh - 10 months ago 344
PHP Question

how to pass custom parameter in facebook sharer link

Code 1:

<a id="button" rel="nofollow" href="http://www.facebook.com/share.php?" onclick="return fbs_click()" target="_blank">
function fbs_click() {

return false;

Here Title "t" is not working but i want to display custom title, summary, url and image so, I tried something like this

Code 2:

<a id="button" href="http://www.facebook.com/sharer.php?
&p[url]=<?php echo $pressurl;?>
&p[summary]=containsummary ">

In both the cases nothing happened it automatically get some content (title,image,summary) from the above mentioned url and I want to display custom title,image and summary in facebook share page and i dono how to use og meta tag and what s=100 it means?..


Instead of using the sharer.php script on Facebook, you can use the Facebook JavaScript SDK to make a custom share dialog.

<!-- include Facebook JavaScript SDK -->

<!-- share link -->
<a href="#" class="share-btn">Share to Facebook</a>

<script type="text/javascript">
function fb_share() {
    // facebook share dialog
    FB.ui( {
        method: 'feed',
        name: "Your Page Title",
        link: "https://www.webniraj.com/link-to-page/",
        picture: "https://stackexchange.com/users/flair/557969.png",
        caption: "Some description here"
    }, function( response ) {
        // do nothing
    } );


// add click event to link using jQuery
  $('.share-btn').on( 'click', fb_share );

This will create a nice popup for sharing to Facebook, and you can easily change the title, description, and picture attributes in the JavaScript. Working demo available here.