I'm hoping someone can help me. Getting this error when trying to update to twitter via 'http:// twitter.com/direct_messages/new.json'
{"request":"/direct_messages/new.json","error":"Invalid request."} I'm using PHP with a script i copied from the web which is suppose to monitor a server and update the twitter account if the server goes offline. here's the code i copied from the web: <?php // Specify the target URL in your server $targetUrl = 'http://YOUR_SERVER_URL'; // Specify what the response is from the server $targetText = 'Hello from Daredevil'; // We will be using cURL for fetching the content $ch = curl_init(); // Set the params curl_setopt($ch, CURLOPT_URL, $targetUrl); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Get the response $response = curl_exec($ch); curl_close($ch); // Are things in right place ? if ($response == $targetText) { die('Site is up and running!'); } // Nope, so here are the sender's twitter info $username = 'SENDER_TWITTER_USERNAME'; $password = 'SENDER_TWITTER_PASSWORD'; // Receiver's twitter username $receiver = 'RECEIVER_TWITTER_USERNAME'; // Alert message to send $message = 'Daredevil is not responding, please fix ASAP!'; // The Twitter API address (new direct message) $url = 'http://twitter.com/direct_messages/new.json'; // We will be using cURL for this $ch = curl_init(); // Set the params curl_setopt($ch, CURLOPT_URL, "$url"); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$receiver&text= $message"); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); // Send the request $response = curl_exec($ch); curl_close($ch); // Success or failure if (!empty($response)) { echo 'Recipient has been notified.'; } else { echo 'No response from twitter.'; } ?>