-2

I am sharing data to twitter.com and facebook.com. Sharing to facebook means automatically sending image, title, and domain it is working fine.

I want to implement in twitter, but it is not taking title and image.

while implementing twitter it is taking only the URL path,ig click the Share on Twitter

  <!-- Load Facebook SDK for JavaScript -->
  <div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = 'https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.12';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

  <!-- Your share button code -->
 <div class="fb-share-button" data-href="http://g2evolution.in/spreadit_API/event-details.php?id=MQ==&postedCustonerId=MQ==&eventType=UHVibGlj" data-layout="button_count" data-size="small" data-mobile-iframe="true"><a target="_blank" href="http://g2evolution.in/spreadit_API/event-details.php?id=MQ==&postedCustonerId=MQ==&eventType=UHVibGlj" class="fb-xfbml-parse-ignore">Share on Facebook</a></div> <br><br>

<a href="https://twitter.com/intent/tweet?url=http://g2evolution.in/spreadit_API/event-details.php?id=MQ==&postedCustonerId=MQ==&eventType=UHVibGlj">Share on Twitter</a>
James Z
  • 12,209
  • 10
  • 24
  • 44
Roobathi N
  • 1
  • 1
  • 2
  • 1
    Please learn how to use the formatting tools provided for writing questions properly. Don't mark random words as `code`. Don't mark content that is not a quotation as a quote (and if you do quote someone, then tell us who you are quoting!). You should also provide a [mcve]; We can't tell what is wrong with your code without seeing it. – Quentin Apr 09 '18 at 12:59
  • Your text was also incredible confusing. Next time you might want to check it with someone else first before posting, or maybe finding a place where you can use your native language. – James Z Apr 09 '18 at 14:23

1 Answers1

0

In regards to the share link, you can use the code below:

<?php

    $title = 'Title here';
    $short_url = 'http://shorturl.co';
    $url = 'http://fullurl.com';

    $twitter_params = 
    '?text=' . urlencode($title) . '+-' .
    '&amp;url=' . urlencode($short_url) . 
    '&amp;counturl=' . urlencode($url) .
    '';


    $link = "http://twitter.com/share" . $twitter_params . "";
?>

<a href="<?php echo $link; ?>">Share on Twitter</a>

<?php 
// rest of your code
?>

For sharing the image as facebook, you might want to look a previous answer.

Ali_k
  • 1,642
  • 1
  • 11
  • 20
  • `http://g2evolution.in/spreadit_API/event-details.php?id=MQ==&postedCustonerId=MQ==&eventType=UHVibGlj` above URL i want to use, `title` and `image`, can you make fiddle – Roobathi N Apr 09 '18 at 13:08
  • ,I am not getting your code,Kindly update your answer based On my `URL` – Roobathi N Apr 09 '18 at 13:14