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. Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.