Boxerman Posted April 23, 2012 Share Posted April 23, 2012 Hi guys, I'm using a twitter script that grabs the title and publishings it like so: "Title - Read More at..." I was wondering how i would be able to post the direct link into twitter.. like news.php?id=1 for example. $tweet->post('statuses/update', array('status' => ''.$_POST[title].' - more at MY URL')); This part is in the script to publish automatically when the users adds to the news database. How am i able to get the ID just after the posting of the news? Thanks! Link to comment https://forums.phpfreaks.com/topic/261463-posting-link-to-twitter-link-to-id/ Share on other sites More sharing options...
scootstah Posted April 23, 2012 Share Posted April 23, 2012 If I'm understanding you correctly, you want mysqli_insert_id or the equivalent. Link to comment https://forums.phpfreaks.com/topic/261463-posting-link-to-twitter-link-to-id/#findComment-1339796 Share on other sites More sharing options...
chrisguk Posted April 23, 2012 Share Posted April 23, 2012 <?php /* ---------------------------------------- */ // Change these parameters with your Twitter // user name and Twitter password. /* ---------------------------------------- */ $twitter_username ='yourTwitterUserName'; $twitter_psw ='yourTwitterPassword'; /* ---------------------------------------- */ /* Don't change the code beloW /* ---------------------------------------- */ require('twitterAPI.php'); if(isset($_POST['twitter_msg'])){ $twitter_message=$_POST['twitter_msg']; if(strlen($twitter_message)<1){ $error=1; } else { $twitter_status=postToTwitter($twitter_username, $twitter_psw, $twitter_message); } } /* ---------------------------------------- */ ?> <!-- Send message to Twitter --> <?php if(isset($_POST['twitter_msg']) && !isset($error)){?> <div class="msg"><?php echo $twitter_status ?></div> <?php } else if(isset($error)){?> <div class="msg">Error: please insert a message!</div> <?php }?> <p><strong>What are you doing?</strong></p> <form action="insertTwitterMsg.php" method="post"> <input name="twitter_msg" type="text" id="twitter_msg" size="40" maxlength="140"/> <input type="submit" name="button" id="button" value="post" /> </form> Link to comment https://forums.phpfreaks.com/topic/261463-posting-link-to-twitter-link-to-id/#findComment-1339968 Share on other sites More sharing options...
Boxerman Posted April 24, 2012 Author Share Posted April 24, 2012 mysqli_insert_id() is perfect thank you Link to comment https://forums.phpfreaks.com/topic/261463-posting-link-to-twitter-link-to-id/#findComment-1340062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.