coolbeansdude51 Posted March 3, 2009 Share Posted March 3, 2009 Hello everyone, I am trying to get this Curl call to work. All the info for the API can be found here http://tatango.com/developers/tatango_api/docs I am attempting to do the send a message call. Which is looks like this. curl -u360XXXXXXX:password http://tatango.com/groups/31/messages.xml -dmessage[content]='Here is my message' -i I attempt to form it with php curl and I just get lost. This is what I have come up with: <?php // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://tatango.com/groups/31/messages.xml"); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); ?> I am completely lost on how to form this. Any ideas? Thanks, -Adam Link to comment https://forums.phpfreaks.com/topic/147809-solved-curl-help/ Share on other sites More sharing options...
coolbeansdude51 Posted March 5, 2009 Author Share Posted March 5, 2009 Anyone? Link to comment https://forums.phpfreaks.com/topic/147809-solved-curl-help/#findComment-777060 Share on other sites More sharing options...
btherl Posted March 5, 2009 Share Posted March 5, 2009 The curl options are listed here: http://sg2.php.net/manual/en/function.curl-setopt.php It looks like you need to set the username and password (-u), and also set the post data (-d), and make sure you are doing a post. Since the original command line had the -i option, you probably want CURLOPT_HEADER set to 1 rather than 0. Link to comment https://forums.phpfreaks.com/topic/147809-solved-curl-help/#findComment-777098 Share on other sites More sharing options...
coolbeansdude51 Posted March 5, 2009 Author Share Posted March 5, 2009 Alright. Looked at all of that. How about something like this? I tried it ... didn't work but am I on the right track? <?php error_reporting('ALL'); $username = 'username'; $password = 'password'; $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "https://tatango.com/groups/YOURID/messages.xml"); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "dmessage[content]=test"); curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); curl_setopt($curl_handle, CURLOPT_HEADER, 0); $buffer = curl_exec($curl_handle); curl_close($curl_handle); ?> Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/147809-solved-curl-help/#findComment-777103 Share on other sites More sharing options...
coolbeansdude51 Posted March 5, 2009 Author Share Posted March 5, 2009 BAH! I figured it out! I completely forgot that I left in the D. It should look like this: <?php error_reporting('ALL'); $username = 'username'; $password = 'password'; $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "https://tatango.com/groups/YOURID/messages.xml"); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "message[content]=test"); curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); curl_setopt($curl_handle, CURLOPT_HEADER, 0); $buffer = curl_exec($curl_handle); curl_close($curl_handle); ?> Link to comment https://forums.phpfreaks.com/topic/147809-solved-curl-help/#findComment-777106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.