3
Contributors
6
Replies
44
Views
3 Years
Discussion Span
Last Post by davy_yg
0

How to control the text being tweeted? Is it by the html <title> ?

This is the code that I have so far:

event_article.php

<?php

include('include/con_database.php');

$result = mysql_query("SELECT * FROM dynamic_content WHERE id='".$_GET["id"]."'");

while ($data = mysql_fetch_array($result)){

echo '<center>'.'<div id="title">'.$data['title'].'</div>'.'</center>'.'<br>';
echo '<center>'.'<div id="images">'.'<img src="images/events/' . $data['images'] . '" >'.'</div>'.'</center>'.'<br>';
/*height="300px" width="400px" */
echo '<div id="text">'.$data['content'].'</div>'.'<br>';

echo '<div class="fb-share-button" data-href="http://developers.facebook.com/docs/plugins/" data-type="button_count"></div>';

}
?>

<br><br>

<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

</div>

<br><br>


</div>

</body>

<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>

I would like the text that is being tweeted is determined by $data['title'].

How to code it?

0

Hello,

I finally figure out how to link the twitter share button and share the title but I cannot show the facebook share button, I wonder why?

This is my codes:

event_article.php

<body>
<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 = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div id="titlebar"><div id="title"><h2 class="title">Events</h2></title></div>

<div id="container">


<div id="banner">
<div id="desc">
<h1></h1>


<br><br><br>
<?php

include('include/con_database.php');

$result = mysql_query("SELECT * FROM dynamic_content WHERE id='".$_GET["id"]."'");

while ($data = mysql_fetch_array($result)){

echo '<center>'.'<div id="title">'.$data['title'].'</div>'.'</center>'.'<br>';
echo '<center>'.'<div id="images">'.'<img src="images/events/' . $data['images'] . '" >'.'</div>'.'</center>'.'<br>';
/*height="300px" width="400px" */
echo '<div id="text">'.$data['content'].'</div>'.'<br>';

echo '<div class="fb-share-button" data-href="http://localhost/IndonusaCMS/event_article.php?id=137" data-type="button_count"></div>';

/* http://localhost/IndonusaCMS/event_article.php?id='.$_GET["id"].' */

echo '<a href="https://twitter.com/share" class="twitter-share-button" data-text="'.$data['title'].'">Tweet</a>';

}
?>

<br><br>

<div class="fb-share-button" data-href="http://localhost/IndonusaCMS/event_article.php?id=137" data-type="button_count"></div>
0

Thanks that part works. Now, whatif I would like to share the article title instead of url. The twitter part works, but I cannot apply it to facebook.

event_article.php

<?php

include('include/con_database.php');

$result = mysql_query("SELECT * FROM dynamic_content WHERE id='".$_GET["id"]."'");

while ($data = mysql_fetch_array($result)){

echo '<center>'.'<div id="title">'.$data['title'].'</div>'.'</center>'.'<br>';
echo '<center>'.'<div id="images">'.'<img src="images/events/' . $data['images'] . '" >'.'</div>'.'</center>'.'<br>';
/*height="300px" width="400px" */
echo '<div id="text">'.$data['content'].'</div>'.'<br>';

echo '<div class="fb-share-button" data-href="http://127.0.0.1/IndonusaCMS/event_article.php?id=137" data-type="button_count"></div>';

echo '<div class="fb-share-button" data-type="button_count"></div>';
echo '<br><br>';

/* http://localhost/IndonusaCMS/event_article.php?id='.$_GET["id"].' */

echo '<div id="twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-text="'.$data['title'].'">Tweet</a></div>';

}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.