Amazon transcoder change MIME type - amazon

I am using Amazon transcoder to convert videos from MP4 to flv but the generated file has the MIME type video/MP4, i need it to be changed to video/x-flv
My code is:
$result = $s3ClientTranscoder->createJob(array(
'PipelineId' => 'xxxxxxxxxxxxxx-xxxxxx',
'Input' => array(
'Key' => $original_url
),
'Output' => array(
'Key' => $converted_url,
'PresetId' => '1351620000001-000030'
),
));

Related

How to read every field of a web response of messagebird

Here is the response i receive after send every successful sms. Output of php code print_r($MessageResult); is give below.
MessageBird\Objects\Message Object
(
[id:protected] => op34f300d57a4217xc9d48be7b890fd4
[href:protected] => https://rest.messagebird.com/messages/ae3956ccd57af2f7939d48be7b891qd4
[type] => sms
[originator] => +12223334444
[body] => sms text body is here
[typeDetails] => stdClass Object
(
)
[datacoding] => plain
[mclass] => 1
[scheduledDatetime] =>
[createdDatetime:protected] => 2021-06-25T18:55:38+00:00
[recipients] => stdClass Object
(
[totalCount] => 1
[totalDeliveryFailedCount] => 0
[items] => Array
(
[0] => MessageBird\Objects\Recipient Object
(
[recipient] => 19998886666
[status] => sent
[statusDatetime] => 2021-06-25T18:55:38+00:00
)
)
)
[reportUrl] =>
)
I get correct value for php code
echo $MessageResult->body
But I have tried by php code echo $MessageResult->id; and get error: Fatal error: Uncaught Error: Cannot access protected property MessageBird\Objects\Message::$id
My question is, How do i read id value? (which is here op34f300d57a4217xc9d48be7b890fd4)

How to apply extension hook in expressionengine

I'm working on expressionengine v2 and i have followed the docs at their site to make extension hooks, i've created a file in third party folder and install that from cp(control panel). Now i don't know how to call that function using hook just to show some text.
$hooks = array(
'after_channel_entry_insert' => 'after_channel_entry_insert',
'before_channel_entry_update' => 'before_channel_entry_update'
);
foreach ($hooks as $hook_name => $method_name) {
$data[] = array(
'class' => __CLASS__,
'method' => $method_name,
'hook' => $hook_name,
'settings' => serialize($this->settings),
'priority' => 10,
'version' => $this->version,
'enabled' => 'y'
);
}
//insert data in extension table
ee()->db->insert_batch('extensions', $data);
//now i want to call this function on hook
function after_channel_entry_insert($data = '') {
die('after_channel_entry_insert');
}

Temperature and Humidity from Nest Protect

The Nest Protect (smoke and CO alarm) can measure temperature and humidity but neither the official or unofficial API's appear to allow access to this data. Is anyone working on a work around? Any line of sight to accessing this data? Suggestions? Thanks!
$infos = (object) array(
'current_state' => (object) array(
'mode' => $mode,
'temperature' => $this->temperatureInUserScale((float) $this->last_status->shared->{$serial_number}->current_temperature),
'humidity' => $this->last_status->device->{$serial_number}->current_humidity,
'ac' => $this->last_status->shared->{$serial_number}->hvac_ac_state,
'heat' => $this->last_status->shared->{$serial_number}->hvac_heater_state,
'alt_heat' => $this->last_status->shared->{$serial_number}->hvac_alt_heat_state,
'fan' => $this->last_status->shared->{$serial_number}->hvac_fan_state,
'auto_away' => $this->last_status->shared->{$serial_number}->auto_away, // -1 when disabled, 0 when enabled (thermostat can set auto-away), >0 when enabled and active (thermostat is currently in auto-away mode)
'manual_away' => $manual_away,
'leaf' => $this->last_status->device->{$serial_number}->leaf,
'battery_level' => $this->last_status->device->{$serial_number}->battery_level
),
'target' => (object) array(
'mode' => $target_mode,
'temperature' => $target_temperatures,
'time_to_target' => $this->last_status->device->{$serial_number}->time_to_target,
Add this:
'humidity' => $this->last_status->device->{$serial_number}->target_humidity, //added by Rick Ammazzini
'humidity_enabled' => $this->last_status->device->{$serial_number}->target_humidity_enabled //added by Rick Ammazzini
),
'serial_number' => $this->last_status->device->{$serial_number}->serial_number,
'scale' => $this->last_status->device->{$serial_number}->temperature_scale,
'location' => $structure,
'line_power_present' => $this->last_status->device->{$serial_number}->line_power_present,
'network' => $this->getDeviceNetworkInfo($serial_number),
'name' => !empty($this->last_status->shared->{$serial_number}->name) ? $this->last_status->shared->{$serial_number}->name : DEVICE_WITH_NO_NAME,
'where' => isset($this->last_status->device->{$serial_number}->where_id) ? isset($this->where_map[$this->last_status->device->{$serial_number}->where_id]) ? $this->where_map[$this->last_status->device->{$serial_number}->where_id] : $this->last_status->device->{$serial_number}->where_id : ""
);
if($this->last_status->device->{$serial_number}->has_humidifier) {
$infos->current_state->humidifier= $this->last_status->device->{$serial_number}->humidifier_state;
$infos->target->humidity = $this->last_status->device->{$serial_number}->target_humidity;
$infos->target->humidity_enabled = $this->last_status->device->{$serial_number}->target_humidity_enabled;
}
return $infos;
}

installing 'EdpModuleLayouts' to zendframework 2

i am trying to install 'EdpModuleLayouts'
i have followed the instruction for the module here:
i also followed the issue here:
i. e; I placed the following code in my application.config.php?
return array(
'modules' => array(
... ,
'EdpModuleLayouts'
)
);
i then placed the following code in my module config
'view_manager' => array(
'template_path_stack' => array(
'workers' => __DIR__ . '/../view',
'Workers/layout' => __DIR__ . '/../view/layout/layout.phtml'
),
),
'module_layouts' => array(
'Workers' => 'Workers/layout'
),
i got the following error report:
Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException'
with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render
template "Workers/layout"; resolver could not resolve to a file' in
zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php
on line 499
The error message is so specific.
Unable to render template "Workers/layout"
This means that there is no template Workers/layout defined within the view_manager configuration. And the trick here is that you made a simple mistake of placing the configuration at the wrong place.
template_path_stack is used to give the view_manager information about some folders where template files are mapped going by their file-path.
template_map is used to give the view_manager information about which file covers a specific template.
The difference of the two can easily be seen when checking the module.config.php of the ZendSkeletonApplication. With this in mind, all you have to do is to change your configuration.
Another hint: don't CamelCase configuration keys, keep them lowercased ;)
'view_manager' => array(
'template_path_stack' => array(
'workers' => __DIR__ . '/../view',
),
'template_map' => array(
// consider to make this lowercase "workers/layout"
'Workers/layout' => __DIR__ . '/../view/layout/layout.phtml'
)
),
'module_layouts' => array(
'Workers' => 'Workers/layout'
),

how to set default theme in twig?

I use a silex with twig;
I create custom form_div_layout and put it in the webroot( for example)
I register TwigService provider like this
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__ . '/../views',
'twig.options' => array(
'cache' => __DIR__ . '/../cache/twig',
'strict_variables' => false
),
'twig.form.templates'=> [WEBROOT . '/form_div_layout.twig']
));
but i have an error
Twig_Error_Loader: Template "/home/versh/sale/web/form_div_layout.twig" is not defined () in "layout.twig" at line 52.
how to register theme correctly ?
I know that if i put theme in the twig.path it will work, but this is not solution
I'm using Twig with namespaces and I think it is the most flexible practice:
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.options' => array(
'cache' => true,
'strict_variables' => true,
'debug' => false,
'autoescape' => true
)
));
// set namespace for your application
$app['twig.loader.filesystem']->addPath(WHERE_EVER_YOU_WANT_PATH, 'yourApplication');
Now you can render templates using the namespace:
return $app['twig']->render('#yourApplication/sample.twig', array());
you can define as many namespaces as you need.
You have to add base template form_div_layout.html.twig to twig.form.templates option too.
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/../views',
'twig.options'=>array(
'cache' => __DIR__.'/../cache',
),
'twig.form.templates' => array(
'form_div_layout.html.twig',
'theme/form_div_layout.twig'
),
));

Resources