1

I'm working in getting a connection to cloudant done.

The following is using sag library for 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);
}
?>

However I'm not getting expected result (). The view does work, if used just in the url bar.

The response is:

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){ .............

Is there something I'm not using corretly in the php script? (removed current password + username as well as account, but they're there).

Javier S
  • 115
  • 2
  • 13

1 Answers1

0

Curl error 7 means you are unable to connect to the host or proxy:

CURLE_COULDNT_CONNECT (7)

Failed to connect() to host or proxy.

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

When you connect to the URL from your browser if your browser is using a proxy, you will also need to configure sag to use that proxy.

Also, when you say that you replaced the account in your code example, did you mean that you replaced user in $sag = new Sag('user.cloudant.com'); with your actual username? If not, you will need to use your actual username.

Chris Snow
  • 23,813
  • 35
  • 144
  • 309
  • Hello, thank you for your time. Indeed I'm using th correct username (the one I can access cloudant with, at least from their own page). I will have a look at that link, the browser I'm working with is firefox, hopefully I'll be able to find how to fix this. regards. – Javier S Oct 08 '14 at 16:10