2010-11-11 19 views
0

我用這個來登錄到索倫森360 API嘗試:PHP:發佈數據REST API(索倫森360)

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); 

這是我在瀏覽器中看到:

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

以下是API方法的鏈接:http://developers.sorensonmedia.com/api/accounts/login

任何人都可以請向我解釋我做錯了什麼?

回答

0

我從來不喜歡cURL。你爲什麼不嘗試更全功能的HTTP客戶端,如Zend_Rest_Client或更多的裸骨,Zend_Http_Client

+0

這是在一個共享的主機,並沒有安裝Zend,我沒有安裝任何東西...... :( – 2010-11-11 03:32:28

+0

Zend框架只是一堆PHP文件,你可以通過將文件上傳到你的網站來安裝整個框架或者只是你需要的組件(和它們的依賴關係) – Phil 2010-11-11 03:38:18

+0

我上傳了Zend文件,並使用了Zend_Rest_Client,並經過一些試驗和錯誤,能夠得到我需要的數據。謝謝。 – 2010-11-11 23:24:01