Jump to content

Twitter status with a variable


treeleaf20

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.