PHP:将数据发布到REST API(Sorenson 360) [英] PHP: posting data to REST API (Sorenson 360)
本文介绍了PHP:将数据发布到REST API(Sorenson 360)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已尝试使用此登入sorenson 360 API:
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)
以下是API方法的链接: http://developers.sorensonmedia.com / api / accounts / login
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?
推荐答案
我从来不喜欢cURL。为什么不尝试更全面的HTTP客户端,例如 Zend_Rest_Client 或更裸露的骨头, Zend_Http_Client
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
这篇关于PHP:将数据发布到REST API(Sorenson 360)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文