Jump to content

[SOLVED] Curl help


coolbeansdude51

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.