Why is AWS MediaConverter validation failing? - php

I am trying to set up wav -> mp3 conversion through AWS, I've followed documentation closely but I can't find anything about the problem I am facing so hoping someone can help here. Here is my code to start a conversion on AWS:
$job_settings = '{
"TimecodeConfig": {
"Source": "ZEROBASED"
},
"OutputGroups": [
{
"Name": "File Group",
"Outputs": [
{
"ContainerSettings": {
"Container": "RAW"
},
"AudioDescriptions": [
{
"AudioTypeControl": "FOLLOW_INPUT",
"AudioSourceName": "Audio Selector 1",
"CodecSettings": {
"Codec": "MP3",
"Mp3Settings": {
"Bitrate": 192000,
"Channels": 2,
"RateControlMode": "CBR",
"SampleRate": 48000
}
},
"LanguageCodeControl": "FOLLOW_INPUT"
}
]
}
],
"OutputGroupSettings": {
"Type": "FILE_GROUP_SETTINGS",
"FileGroupSettings": {
"Destination": "{DESTINATION}"
}
}
}
],
"AdAvailOffset": 0,
"Inputs": [
{
"AudioSelectors": {
"Audio Selector 1": {
"Tracks": [
1
],
"Offset": 0,
"DefaultSelection": "DEFAULT",
"SelectorType": "TRACK",
"ProgramSelection": 1
}
},
"FilterEnable": "AUTO",
"PsiControl": "USE_PSI",
"FilterStrength": 0,
"DeblockFilter": "DISABLED",
"DenoiseFilter": "DISABLED",
"InputScanType": "AUTO",
"TimecodeSource": "ZEROBASED",
"FileInput": "{INPUT}"
}
]
}';
//Job starts here
$job_settings = json_decode($job_settings, true);
$convert_client = new MediaConvertClient(array(
'version' => '2017-08-29',
'region' => $this->login_details->region,
'credentials' => $this->credentials
));
try {
$res = $convert_client->describeEndpoints([]);
} catch(AwsException $e) {
//echo $e->getMessage();
return null;
}
//print_r($res);
$single_endpoint = $res['Endpoints'][0]['Url'];
$convert_client = new MediaConvertClient(array(
'version' => '2017-08-29',
'region' => $this->login_details->region,
'credentials' => $this->credentials,
'endpoint' => $single_endpoint
));
$res = $client->createJob(array(
"Role" => "arn:aws:iam::{$this->login_details->account_number}:role/MediaConvert_Default_Role",
"Settings" => $job_settings,
"Queue" => "arn:aws:mediaconvert:{$this->login_details->region}:{$this->login_details->account_number}:queues/Default"
));
I grabbed the JSON by creating a conversion job on AWS Console and copying the JSON of the job, the destination and input tags are replaced in the json before decoding to assoc array however I am getting an error of the following:
Error executing "CreateJob" on "aws_url"; AWS HTTP error: Client error: POST aws_url resulted in a 400 Bad Request response: { "errorType": "BadRequestException", "httpStatus" : 400, "requestId" : "-----------", (truncated...) BadRequestException (client): /outputGroups/0/outputs/0/audioDescriptions/0/codecSettings: Should match exactly one schema defined in "oneOf" | /outputGroups/0/outputs/0/audioDescriptions/0/codecSettings: Should have at least 2 properties | /outputGroups/0/outputs/0/audioDescriptions/0/codecSettings/codec: Should be equal to one of the allowed values in ["PASSTHROUGH","OPUS","VORBIS"]
This is using aws-3.93.3 PHP SDK. Any idea why this happens? Of course the job runs perfectly fine if ran through console.

Actually I just found what I suspected was the case; this version of the library does not yet support MP3 ingestion as outlined here:
https://github.com/aws/aws-sdk-php/blob/master/CHANGELOG.md
Updating to the newest version solved this issue.

Related

Symfony 5 - Mangopay post card info's request take too much time

I have a problem with a POST to add the informations of a credit card.
I'm using MangoPay's API to implement the payment method.
I've installed mangopay/php-sdk-v2 et http-client pour gérer les API.
To add a credit card, I have to create a token.
The resulted token is an object with these keys:
{
"Id": "136943412",
"Tag": null,
"CreationDate": 1649425095,
"UserId": "135643537",
"AccessKey": "1X0m87dmM2LiwFgxPLBJ",
"PreregistrationData": "Qi7oou23Q8d9B3xUpjdMucwiSczJqPyOPNZWThaZUKnrBt3dR9IXdzkIKyiibnTP2ddFLVXdicolcUIkv_kKEA",
"RegistrationData": null,
"CardId": null,
"CardType": "CB_VISA_MASTERCARD",
"CardRegistrationURL": "https://homologation-webpayment.payline.com/webpayment/getToken",
"ResultCode": null,
"ResultMessage": null,
"Currency": "EUR",
"Status": "CREATED"
}
After that, I have to do a POST with the URL give by the CardRegistrationURL.
Its body will have five keys to enter:
data (its value => PreregistrationData), accessKeyRef, cardNumber, cardExpirationDate and cardCvx.
// ApiUser.php
public function Registration($id, $form)
{
$CardRegistration = new \MangoPay\CardRegistration();
$CardRegistration->UserId = $id;
$CardRegistration->Currency = "EUR";
$CardRegistration->CardType = "CB_VISA_MASTERCARD";
$Result = $this->mangoPayApi->CardRegistrations->Create($CardRegistration);
$this->registration = $Result;
$respose = $this->client->request(
'POST',
$Result->CardRegistrationURL,
[
'headers' => [
'Content-Type' => [
'application/x-www-form-urlencoded',
'application/json',
],
'Connection' => 'keep-alive'
],
'json' => [
'data' => $Result->PreregistrationData,
'accessKeyRef' => $Result->AccessKey,
'cardNumber' => $form['cardnumber']->getData(),
'cardExpirationDate ' => $form['cardexpdate']->getData(),
'cardCvx' => $form['cardcvx']->getData(),
]
]
);
return [
$response,
$Result
];
}
If it worked, I should have as a result a string that start by data=.
But an error occurs:
All query attempts failed for homologation-webpayment.payline.com: No response for 'homologation-webpayment.payline.com' (A) from any nameserver within 3000 ms after 2 attempts, tried udp://192.168.1.254:53, udp://192.168.1.254:53, No response for 'homologation-webpayment.payline.com' (AAAA) from any nameserver within 3000 ms after 2 attempts, tried udp://192.168.1.254:53, udp://192.168.1.254:53

i can't nested add in elasticsearch

i have a problem with elasticsearch
when i send request for add nested object with elasticseach script in postman it work but when i wanna send request for add new object in elasticseach , All objects in my index disappear.
it not work , this eliminates all other objects in elasticsearch and only add itself:
$params = [
'script' => [
'source' => 'ctx._source.products.add(params.products)',
'lang'=>'painless',
'params' =>['id'=>1,'name'=>'john']
]
];
$http = new Client();
$result = $http->request('post','http://my_server/new_frotel/_update/123', [
'body' =>$params,
'headers'=>[
'content-type'=>'application/json'
]
])
but it work in postman
POST : http://my_server/new_frotel/_update/123
{
"script": {
"source": "ctx._source.products.add(params.products)",
"lang": "painless",
"params": {
"products": {
"id":1,
"name":"john"
}
}
}
}

How do I match entries in the elasticsearch containing dashes (-)

ElasticSearch tokenizes the data.
So "this-that" gets split into 2 tokens.
If it makes a difference, I am using the 6.6 version of ES.
I have documents, that have different fields, such as title, descriptions, name, etc.
In order for us to have a unique identifier, the text in Title "This that" get slugified into "this-that".
I am trying to to query for "this-that" that would return that one document.
I have tried all sorts of things. I tried suggestions from other questions in this forum, as well as instructions in the https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html page.
Unfortunately, nothing seems to work.
Your help would be greatly appreciated.
Thank you in advance.
https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html
<?php
require 'vendor/autoload.php';
use Elasticsearch\ClientBuilder;
$hosts = ['localhost:9200'];
$client = ClientBuilder::create()
->setHosts($hosts)
->build();
$params = array();
$params = [
'index' => 'shows',
'type' => '_doc',
'body' => [
'size'=> 10000,
'query' => [
'bool' => [
'must' => [ 'match' => [ 'name' => 'this-that'] ],
]
]
]
];
$response = $client->search($params);
print_r($response);
?>
There are no errors, but it finds all instances with the word "this" and the word "that" in the name field.
I would like to get just the one document back!
You can experiment with analyzers and tokenizers using Kibana console or http:
curl -XPOST "http://localhost:9200/_analyze" -H 'Content-Type: application/json' -d'{ "analyzer": "standard", "text": "this-that"}'
{
"tokens" : [
{
"token" : "this",
"start_offset" : 0,
"end_offset" : 4,
"type" : "<ALPHANUM>",
"position" : 0
},
{
"token" : "that",
"start_offset" : 5,
"end_offset" : 9,
"type" : "<ALPHANUM>",
"position" : 1
}
]
}
curl -XPOST "http://localhost:9200/_analyze" -H 'Content-Type: application/json' -d'{ "analyzer": "keyword", "text": "this-that"}'
{
"tokens" : [
{
"token" : "this-that",
"start_offset" : 0,
"end_offset" : 9,
"type" : "word",
"position" : 0
}
]
}
To have always exact match for field, you must use keyword-tokenization. You can do it like this:
PUT test-index
{
"mappings": {
"properties": {
"name": {
"type": "text",
"analyzer": "keyword"
}
}
}
}
Which is exactly same as defining field as a keyword type to begin with:
PUT test-index2
{
"mappings": {
"properties": {
"name": {
"type": "keyword"
}
}
}
}

FCM Android Notification sound issue

I am trying to send notification using php to Android Application, and which is working fine without sound. I am receiving the notification both foreground and background as expected.
Here is the PHP code,
<?php
$token = $_GET['token'];
$action = $_GET['action'];
$msgTitle = $_GET['msgTitle'];
$msgDescription = $_GET['msgDescription'];
$notificationTitle = $_GET['notificationTitle'];
require './google-api-php-client-2.2.2/vendor/autoload.php';
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setAuthConfig('./testPrjoectAPP-firebase-adminsdk-9hn21-22c1b3f426.json');
$client->addScope('https://www.googleapis.com/auth/firebase.messaging');
$httpClient = $client->authorize();
$project = "testPrjoectAPP";
$message = [
"message" => [
"notification" => [
"body" => "Message FCM",
"title" => $notificationTitle
],
"token" => $token,
"data" => [
"action" => $action,
"msgTitle" => $msgTitle,
"msgDescription" => $msgDescription
]
]
];
$response = $httpClient->post("https://fcm.googleapis.com/v1/projects/{$project}/messages:send", ['json' => $message]);
echo$response->getReasonPhrase(); // OK
?>
But when I add sound parameter to notification payload and execute php I am getting Bad Request error from php.
.
$message = [
"message" => [
"notification" => [
"body" => "Message FCM",
"title" => $notificationTitle,
"sound" => "default"
],
// Send with token is not working
"token" => $token,
"data" => [
"action" => $action,
"msgTitle" => $msgTitle,
"msgDescription" => $msgDescription
]
]
];
Edit
Here is the error message I got while printing with
data: "{\n \"error\": {\n \"code\": 400,\n \"message\": \"Invalid JSON payload received. Unknown name \\\"sound\\\" at 'message.notification': Cannot find field.\",\n \"status\": \"INVALID_ARGUMENT\",\n \"details\": [\n {\n \"#type\": \"type.googleapis.com/google.rpc.BadRequest\",\n \"fieldViolations\": [\n {\n \"field\": \"message.notification\",\n \"description\": \"Invalid JSON payload received. Unknown name \\\"sound\\\" at 'message.notification': Cannot find field.\"\n }\n ]\n }\n ]\n }\n}\n"
As per my comment, You have to use your JSON like following way.
Solution:
The appearance of message in your JSON indicates you are using the HTTP v1 API. The documentation you linked is for the legacy API.
The HTTP v1 API JSON to send a notification with sound for Android and iOS devices should be:
{
"message":{
"token":"your-token-value",
"notification":{
"title":"Test",
"body":"Test message from server"
},
"android":{
"notification":{
"sound":"default"
}
},
"apns":{
"payload":{
"sound":"default"
}
}
}
}
Reference Link is: Unable to add sound to notification payload
Thank you.
Try this:
{
"message":{
"token":"your-token-value",
"notification":{
"title":"Test",
"body":"Test message from server"
},
"android":{
"notification":{
"sound":"default"
}
},
"apns":{
"payload":{
"sound":"default"
}
}
}
}

Google Analtyics not registering transactions when using Measurment protocol

I try to send http request to track eCommerce.
I got response http_code=200 but, I can't see any event or transaction.
Code:
$fields_string = '';
$fields = array(
'v' => 1,
'tid' => "UA-xxxxxx-1",
'cid' => $userid,
't' => 'transaction',
'ti' => $transaction_id,
'tr' => $Transaction_revenue,
'ts' => $Transaction_shipping,
'tt' => $tax,
'cu' =>'EUR'
);
Hit:
v=1&t=event&tid=UA-xxxxxx-1&cid=555&uid=123&ti=21&tr=20&tt=5&ts=2&pa=purchase&ec=Checkout&ea=Purchase
what could be the problem?
Thanks a lot.
What makes you think its not working. I ran your hit against debug collect to verify it. Looks good to me.
https://www.google-analytics.com/debug/collect?v=1&t=event&tid=UA-3731463-1&cid=555&uid=123&ti=21&tr=20&tt=5&ts=2&pa=purchase&ec=Checkout&ea=Purchase
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026t=event\u0026tid=UA-3731463-1\u0026cid=555\u0026uid=123\u0026ti=21\u0026tr=20\u0026tt=5\u0026ts=2\u0026pa=purchase\u0026ec=Checkout\u0026ea=Purchase"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
Did you check the real time reports have you double checked your Tid?
https://www.google-analytics.com/debug/collect?v=1&tid=UA-3731463-1&cid=123&t=transaction&ti=124&tr=1&ts=1&tt=1&cu=EUR
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026tid=UA-3731463-1\u0026cid=123\u0026t=transaction\u0026ti=124\u0026tr=1\u0026ts=1\u0026tt=1\u0026cu=EUR"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
Could also be something with the values you are sending in the second one.
Apparently I cloud not send transaction because my IP was blocked.

Categories