I am working on installing the aws sdk for PHP on my Windows machine (Win7 64 bit) PHP v 5.5.12. I tried using all the 3 methods viz Composer,zip and PHAR mentioned here.All the 3 ways give me the same error as below.
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Space required after the Public Identifier in C:\wamp\www\aws-sdk-php-master\src\Aws\Common\Exception\Parser\DefaultXmlExceptionParser.php on line 41
Here's the function which givess the error
public function parse(RequestInterface $request, Response $response)
{
$data = array(
'code' => null,
'message' => null,
'type' => $response->isClientError() ? 'client' : 'server',
'request_id' => null,
'parsed' => null
);
if ($body = $response->getBody(true)) {
$this->parseBody(new \SimpleXMLElement($body), $data); //THIS LINE GIVES ERROR
} else {
$this->parseHeaders($request, $response, $data);
}
return $data;
}
Here is how I try to use it.
error_reporting(E_ALL);
define('AWS_KEY', 'MyAWSKEY');
define('AWS_SECRET_KEY', 'MYSECRETKEY');
define('HOST', 'http://localhost'); //tried changing host to diff values,but don't
//think thats the issue
// require the AWS SDK for PHP library
require 'aws-autoloader.php';
//require '../../aws.phar';
use Aws\S3\S3Client;
// Establish connection with an S3 client.
$client = S3Client::factory(array(
'base_url' => HOST,
'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY
));
$o_iter = $client->getIterator('ListObjects', array(
'Bucket' => 'mybucketname'
));
foreach ($o_iter as $o) {
echo "{$o['Key']}\t{$o['Size']}\t{$o['LastModified']}\n";
}
Heres the stacktrace
[17-Jul-2014 04:19:01 Europe/Paris] PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\wamp\www\aws-sdk-php-master\src\Aws\Common\Exception\Parser\DefaultXmlExceptionParser.php:41
Stack trace:
#0 C:\wamp\www\aws-sdk-php- master\src\Aws\Common\Exception\Parser\DefaultXmlExceptionParser.php(41): SimpleXMLElement- >__construct('<!DOCTYPE HTML ...')
#1 C:\wamp\www\aws-sdk-php-master\src\Aws\S3\Exception\Parser\S3ExceptionParser.php(33): Aws\Common\Exception\Parser\DefaultXmlExceptionParser->parse(Object(Guzzle\Http\Message\Request), Object(Guzzle\Http\Message\Response))
#2 C:\wamp\www\aws-sdk-php-master\src\Aws\Common\Client\ExpiredCredentialsChecker.php(61): Aws\S3\Exception\Parser\S3ExceptionParser->parse(Object(Guzzle\Http\Message\Request), Object(Guzzle\Http\Message\Response))
#3 C:\wamp\www\aws-sdk-php-master\vendor\guzzle\guzzle\src\Guzzle\Plugin\Backoff\AbstractBackoffStrategy.php(39): Aws\Common\Client\ExpiredCredentialsChecker->getDelay(0, Object(Guzzle\Http\Message\Request), Object(Guzzle\Http\Message\Resp in C:\wamp\www\aws-sdk-php-master\src\Aws\Common\Exception\Parser\DefaultXmlExceptionParser.php on line 41
Tried googling it and learnt might be due to magic_quotes in php.ini to be on,but thats not the case,actually I don't have magic_quotes itself in my ini file. Checked the stack trace and it shows the same error.I am not able to figure out if its a system issue or some configuration problem as I get it for all the methods. Is this a issue with some configuration? OR I am missing something?