PHP cURL authentication issues

14 views
Skip to first unread message

Nick

unread,
Mar 17, 2011, 10:42:01 AM3/17/11
to Sorenson Media Developer Group
I'm trying to connect to the API via PHP and cURL, but I keep coming
up with an error. Below is my code

$username = "m...@email.com";
$password = "********";
define('POSTURL','https://360services.sorensonmedia.com/sessions');
define('POSTVARS',"username=".$username."&password=".$password);
$c = curl_init(POSTURL);
var_dump($c);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_POST,1);
curl_setopt($c, CURLOPT_POSTFIELDS,POSTVARS);
$content = curl_exec($c);
var_dump($content);
echo $content;
curl_close($c);

Here is the response:

resource(4) of type (curl) bool(false)

any help is greatly appreciated.
Message has been deleted

abruno

unread,
Mar 17, 2011, 1:15:02 PM3/17/11
to Sorenson Media Developer Group
Hi Nick:
I was looking at your define() function and the PHP manual says that
"It is
possible to define resource constants, however it is not recommended
and may cause unpredictable behavior." Please see:
http://php.net/manual/en/function.define.php

You could use CURLOPT_URL for the url and make the username and
password protected variables? take a look also at CURLOPT_USERPWD for
authentication.
Ana
Reply all
Reply to author
Forward
0 new messages