简体   繁体   中英

aws-php-sdk error while calling sns api

I'm trying to register a device over SNS to generate its Amazon ARN. While calling the createPlatformEndpoint method, i'm getting this error in dependency library guzzlehttp

<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  fopen(): Invalid php:// URL specified</p>
<p>Filename: src/functions.php</p>
<p>Line Number: 81</p>
<p>Backtrace:</p>
<p style="margin-left:10px">
        File: /Applications/MAMP/htdocs/XXXXX/application/third_party/aws/vendor/guzzlehttp/psr7/src/functions.php
    <br />
        Line: 81
    <br />
        Function: fopen
</p>
<p style="margin-left:10px">
        File: /Applications/MAMP/htdocs/XXXX/application/third_party/aws/vendor/guzzlehttp/psr7/src/Request.php
    <br />
        Line: 53
    <br />
        Function: GuzzleHttp\Psr7\stream_for
</p>

I've looked for solutions and they suggested update the aws sdk version, but its already at 3.31 and guzzle is at this version

"require": {
    "php": ">=5.5",
    "guzzlehttp/psr7": "^1.4",
    "guzzlehttp/promises": "^1.0"
},

tried updating it too, and its at the latest version already. I've looked into the source for the error, and it has

if (is_scalar($resource)) {
    $stream = fopen('php://tmp', 'r+');
    if ($resource !== '') {
        fwrite($stream, $resource);
        fseek($stream, 0);
    }
    return new Stream($stream, $options);
}

I'm sending required params as mentioned in the docs, don't know why its crashing.

$this->SNS->createPlatformEndpoint(['PlatformApplicationArn'=>$arn, 'Token'=>$token, 'CustomUserData' => ENVIRONMENT]);

Not sure what the problem was, but re-installing aws-sdk with composer solved this problem. Although it took the entire data from cache but it solved it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM