treeleaf20 Posted November 12, 2009 Share Posted November 12, 2009 All, I have the following code: $username = 'user'; $password = 'pass!'; $status = urlencode(stripslashes(urldecode('There is a new picture posted. Go check it out now: http://website.com/comment.php?picture_id=$id'))); if ($status) { $tweetUrl = 'http://www.twitter.com/statuses/update.xml'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "$tweetUrl"); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status"); curl_setopt($curl, CURLOPT_USERPWD, "$username:$password"); $result = curl_exec($curl); When I try and post this to Twitter everything posts fine except for the $id. How can I post this? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/181281-twitter-status-with-a-variable/ Share on other sites More sharing options...
mikesta707 Posted November 12, 2009 Share Posted November 12, 2009 variables are not interpolated within single quotes. Basically the code $name = "john"; echo 'hi $john'; would result in hi $john. surround the string with double quotes to parse (or interpolate) the variable Link to comment https://forums.phpfreaks.com/topic/181281-twitter-status-with-a-variable/#findComment-956336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.