douren4075 2017-01-31 07:27
浏览 20
已采纳

aws php sdk - 函数在本地主机和控制台上运行,但在服务器上不在浏览器上运行

I'm having an issue where my php function works when I call it from the server's command line, but not on the web page. It also works on the web page when I have it hosted locally through WAMP.

Any ideas what might be the issue?

function getCFTemplateSummary($CFUrl){
//init client
$client = new CloudFormationClient(array(
    'profile' => 'default',
    'region' => 'us-east-1',
    'version' => '2010-05-15',
    'http' => [ 'verify' => false ]
    ));

    try {
    $result = $client->getTemplateSummary(['TemplateURL' => $CFUrl]);
    }catch(\Aws\CloudFormation\Exception\CloudFormationException $e){
        echo $e->getMessage();
    }catch(\Aws\Exception\AwsException $e){
        echo $e->getMessage();
    }

    echo "<pre>";
    print_r($result);
    echo "inside the function";
    echo "</pre>";
    return $result;

 }

I was able to trace down the issue to this by trial and error commenting ...but not sure how to proceed debugging as I don't see any error messages.

$result = $client->getTemplateSummary(['TemplateURL' => $CFUrl]);
  • 写回答

1条回答 默认 最新

  • duannao3402 2017-01-31 16:32
    关注

    Try catching Exception instead of \Aws\CloudFormation\CloudFormationException, it's possible that a different Exception (e.g., incorrectly configured AWS credentials) is being thrown from your server that you aren't explicitly catching in your current code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?