2014-10-07 32 views
1

我正在努力獲得與cloudant的連接。如何正確連接cloudant + sag

使用下垂庫PHP中的以下內容:

<?php 
header('Content-Type: text/html; charset=utf-8'); 
require_once('../../src/Sag.php'); 

//this credentials are from API key 
$uName=""; 
$pName=""; 

$sag = new Sag('user.cloudant.com'); 
$sag->login($uName, $pName); 
$sag->setDatabase('test'); 


try { 
$result = $sag->get('/test/_design/wordsP/_view/errores'); 
echo ($result); 
} 
catch(Exception $e) { 
error_log("Something's wrong"); 
var_dump($e); 
} 
?> 

但是我沒有得到期望的結果()。如果在網址欄中使用該視圖,它也可以工作。

的迴應是:

object(SagException)#3(6){ 
[ 
    "message:protected" 
]=>string(50)"Sag Error: cURL error #7: couldn't connect to host"[ 
    "string:private" 
]=>string(0)""[ 
    "code:protected" 
]=>int(0)[ 
    "file:protected" 
]=>string(73)"/home2/.../public_html/clant/src/httpAdapters/SagCURLHTTPAdapter.php"[ 
    "line:protected" 
]=>int(134)[ 
    "trace:private" 
]=>array(3){ ............. 

有我不是在PHP腳本中使用corretly的東西嗎? (刪除當前密碼+用戶名以及帳戶,但他們在那裏)。

回答

0

捲曲錯誤7意味着你無法連接到主機或代理:

CURLE_COULDNT_CONNECT(7)

無法連接()到主機或代理。

來源:http://curl.haxx.se/libcurl/c/libcurl-errors.html

當你,如果你的瀏覽器使用代理服務器連接到您的瀏覽器的網址,您還需要配置下垂爲使用代理服務器。

另外,當你說你在你的代碼示例中替換了賬戶,你的意思是你用你的實際用戶名替換了user$sag = new Sag('user.cloudant.com');?如果沒有,您將需要使用您的實際用戶名。

+0

你好,謝謝你的時間。 事實上,我使用的是正確的用戶名(我可以訪問cloudant的用戶,至少從他們自己的頁面)。 我會看看那個鏈接,我正在使用的瀏覽器是firefox,希望我能找到如何解決這個問題。 關於。 – 2014-10-08 16:10:41