开发者

PHP: posting data to REST API (Sorenson 360)

开发者 https://www.devze.com 2023-01-24 06:26 出处:网络
I\'ve tried using this to login to the sorenson 360 API: error_reporting(E_ALL); ini_set(\"display_errors\", 1);

I've tried using this to login to the sorenson 360 API:

error_reporting(E_ALL);
ini_set("display_errors", 1);

$username = "<username>";
$password = "<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_PORT, 443);
curl_setopt($c, CURLOPT_POST,1);
curl_setop开发者_如何学运维t($c, CURLOPT_POSTFIELDS,POSTVARS);
$content = curl_exec($c);

var_dump($content);

curl_close($c);

And this is what i see in the browser:

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

Here is the link for the API method: http://developers.sorensonmedia.com/api/accounts/login

Can anyone please explain to me what i am doing wrong?


I've never liked cURL. Why don't you try a more fully featured HTTP client like Zend_Rest_Client or the more bare bones, Zend_Http_Client

0

精彩评论

暂无评论...
验证码 换一张
取 消