PHP: posting data to REST API (Sorenson 360)

拥有回忆 提交于 2019-12-23 05:35:08

问题


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_setopt($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?


回答1:


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



来源:https://stackoverflow.com/questions/4151104/php-posting-data-to-rest-api-sorenson-360

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!