aws / aws-sdk-php

Official repository of the AWS SDK for PHP (@awsforphp)
http://aws.amazon.com/sdkforphp
Apache License 2.0
6.03k stars 1.22k forks source link

CloudSearchDomainException from sample code on documentation #634

Closed UnbrandedTech closed 9 years ago

UnbrandedTech commented 9 years ago

I love the look of the new documentation and I followed it TO THE T and got this exception.

$client = CloudSearchDomainClient::factory(array(
'version' => '2013-01-01', // This caused an error if I didn't add it someone should put something in the documentation but w/e
'endpoint' => '<my super secret search endpoint>.cloudsearch.amazonaws.com'
));
$res = $client->search(array('query' => 'foobar'));

I run it and BOOM!

PHP message: PHP Fatal error:  Uncaught exception 'Aws\CloudSearchDomain\Exception\CloudSearchDomainException' with message 'Error executing "Search" on "/2013-01-01/search?format=sdk&pretty=true&q=foobar"; AWS HTTP error: cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)'

exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in /var/www/app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:162
Stack trace:
#0 /var/www/app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(125): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 /var/www/app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(90): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlMultiHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 /var/www/app/vendor/guzzlehttp/guzzle/src/Handler/CurlMult"

Any Ideas? The almighty Google has failed me.

jeremeamia commented 9 years ago

Any Ideas?

Make sure you have https:// or http:// in your URL. I think that should fix your issue.

'version' => '2013-01-01', // This caused an error if I didn't add it someone should put something in the documentation but w/e

Here are the docs on 'version'. Where were you reading that might benefit from some clarification?

UnbrandedTech commented 9 years ago

This is the page I was reading http://docs.aws.amazon.com/aws-sdk-php/guide/latest/service-cloudsearchdomain.html

jeskew commented 9 years ago

Those are actually the docs for v2 of the SDK (please excuse the "latest" in the URL; we're working on that). The v3 documentation can be found here.

UnbrandedTech commented 9 years ago

Is there a irc channel or a gitter that I can ask questions? There are a lot of really confusing things in the Documentation. Like

CloudSearchDomainClient->search(
    'highlight' => '<string>' //this is a string
)

but in the api documentation http://docs.aws.amazon.com/cloudsearch/latest/developerguide/highlighting.html

It's in a dot notation:

highlight.field={"max_phrases":<int>,"format":<text / html>,"pre_tag":"*<string>*","post_tag":"*%*"}

How would you do this in the SDK?

UnbrandedTech commented 9 years ago

BTW, @jeremeamia you were right. It works, now I have different Issues.

jeskew commented 9 years ago

As we discussed in the Gitter chat, highlight takes a JSON string with the fields mentioned in the CloudSearch developer guide.

I'm going to go ahead and close the issue, but please feel to reopen it if you have any questions.