Search code examples
phpamazon-web-servicesamazon-elasticacheamazon-elastic-transcoder

Why is my php amazon elastic transcoder working from root but not from a browser?


I am trying to execute a job that will transcode a video file. I have a php file:

<?php
require 'vendor/autoload.php';

use Aws\ElasticTranscoder\ElasticTranscoderClient;

// Create a service locator using a configuration file
$client = ElasticTranscoderClient::factory(array(
        'key'    => 'my key',
        'secret' => 'my secret',
        'region' => 'us-west-2',
));

$result = $client->createJob(array(
        'PipelineId' => 'my pipeline id',
        'Input' => array(
                'Key' => 'video.mp4',
                'FrameRate' => 'auto',
                'Resolution' => 'auto',
                'AspectRatio' => 'auto', 
                'Interlaced' => 'auto',
                'Container' => 'auto',
        ),
        'Output' => array(
                'Key' => 'output.mp4',
                'ThumbnailPattern' => 'thumb{count}.jpg',
                'Rotate' => 'auto',
                'PresetId' => '1351620000001-000010',
        ),
));

?>

and I call this script like transcoder.php

The thing is that if I call this from my root from VPS like php transcoder.php it works just fine, but if I try to call it from my browser (safari, chrome, firefox) I get a

Fatal error: Uncaught exception 'Aws\ElasticTranscoder\Exception\ElasticTranscoderException' in /home/my_user/public_html/test/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php:91 

Stack trace: 

#0 /home/my_user/public_html/test/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php(76): Aws\Common\Exception\NamespaceExceptionFactory->createException('Aws\ElasticTran...', Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response), Array) 

#1 /home/my_user/public_html/test/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/ExceptionListener.php(55): Aws\Common\Exception\NamespaceExceptionFactory->fromResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response)) 

#2 [internal function]: Aws\Common\Exception\ExceptionListener->onRequestError(Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher)) 

#3 /home/my_user/public_html/test/vendor/symfony/event-dispatcher/Symfony/Component/Even in /home/my_user/public_html/test/transcoder.php on line 35

Why does it work from root and but not from browser? I need to access it from the browser.


Solution

  • Try changing the settings from php.ini regarding curl and exec, that`s why you dont have permission to access the script from the browser, but works from root console.