dadamssg Posted June 27, 2009 Share Posted June 27, 2009 Im having trouble writing a script that tweets the title and urls of events getting posted. I go to texas a&M and am trying to tweet the games, so my literal tweet is A&M vs tu Football Game http://www.mysite.com/beta/showevent1.php?id=482 but it only tweets "A"...thats it OR it doesn't show up. but if the tweet doesn't start with "A&M", say the tweet is Blaggards Concert http://www.mysite.com/beta/showevent1.php?id=483 then it works perfect. Tweets every time. I'm also checking to see if the curl is successful....if it is-->update my tweet column to show that it has been tweeted. but on those "A" ones that don't show up on my twitter account, they also get updated for some reason. heres my script <?php include("caneck.inc"); $cxn = mysqli_connect($host,$user,$passwd,$dbname) or die ("Couldn't connect"); //grab the first event that hasn't been tweeted $sql = "SELECT * FROM `test` WHERE tweet = '0' limit 1"; $result = mysqli_query($cxn,$sql) or die (mysqli_error($result)); $list = mysqli_fetch_assoc($result); $agurl = " http://www.mysite.com/beta/showevent1.php?id={$list['eventid']}"; $id = $list['eventid']; $title = stripslashes($list['title']); $tweet = $title." ".$agurl; $username = 'myusername'; $password = 'mypassword'; // The message you want to send // The twitter API address //$urlb = 'http://twitter.com/statuses/update.xml'; // Alternative JSON version $urlb = 'http://twitter.com/statuses/update.json'; // Set up and execute the curl process $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$urlb"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$tweet"); curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); //if tweet is successful, update row to reflect that if(curl_exec($curl_handle)) { $sqr = "Update test SET tweet = '1' WHERE eventid = $id"; $res = mysqli_query($cxn,$sqr) or die (mysqli_error($res)); } else { } curl_close($curl_handle); echo $title; Echo $agurl; echo "<br><br>"; Echo $tweet; ?> Quote Link to comment Share on other sites More sharing options...
papaface Posted June 27, 2009 Share Posted June 27, 2009 & is a way of separating vars in the query. Try curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=".htmlentities($tweet)); Quote Link to comment Share on other sites More sharing options...
dadamssg Posted June 27, 2009 Author Share Posted June 27, 2009 i did this $agurl = " http://www.mysite.com/beta/showevent1.php?id={$list['eventid']}"; $id = $list['eventid']; $title = stripslashes($list['title']); $tweet = $title." ".$agurl; $twitter = htmlentities($tweet); but the same result...i just end up with a freakin "A". Quote Link to comment Share on other sites More sharing options...
papaface Posted June 27, 2009 Share Posted June 27, 2009 Your cURL commands use $tweet not $twitter. Quote Link to comment Share on other sites More sharing options...
.josh Posted June 28, 2009 Share Posted June 28, 2009 urlencode Quote Link to comment Share on other sites More sharing options...
dadamssg Posted June 29, 2009 Author Share Posted June 29, 2009 does the twitter api use urldecode()? that would be the logical solution. i just don't want to send a bunch of percentages and what not Quote Link to comment Share on other sites More sharing options...
dadamssg Posted June 29, 2009 Author Share Posted June 29, 2009 just tested...works beautifully, thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.