I have this static code today that works fine, now i need to make the
order line dynamic. The code is from a e-commerce store.
$order = [
"purchase_country" => "SE",
"purchase_currency" => "SEK",
"locale" => "sv-SE",
"order_amount" => 10000,
"order_tax_amount" => 2000,
"order_lines" => [
[
"type" => "physical",
"reference" => "123050",
"name" => "Tomatoes",
"quantity" => 10,
"quantity_unit" => "kg",
"unit_price" => 600,
"tax_rate" => 2500,
"total_amount" => 6000,
"total_tax_amount" => 1200
],
[
"type" => "physical",
"reference" => "543670",
"name" => "Bananas",
"quantity" => 1,
"quantity_unit" => "bag",
"unit_price" => 5000,
"tax_rate" => 2500,
"total_amount" => 4000,
"total_discount_amount" => 1000,
"total_tax_amount" => 800
]
],
"merchant_urls" => [
"terms" => "https://www.example.com/villkor.php",
"cancellation_terms" => "https://www.example.com/terms/cancellation.html",
"checkout" => "https://www.example.com/_script/checkout.php",
"confirmation" => "https://www.example.com/_script/checkout.php",
// Callbacks
"push" => "https://www.example.com/api/push",
"validation" => "https://www.example.com/api/validation",
"shipping_option_update" => "https://www.example.com/api/shipment",
"address_update" => "https://www.example.com/api/address",
"notification" => "https://www.example.com/api/pending",
"country_change" => "https://www.example.com/api/country"
]
];
Now I need to make order_lines dynamic.
I have tried this code:
$order = [
"purchase_country" => "SE",
"purchase_currency" => "SEK",
"locale" => "sv-SE",
"order_amount" => 10000,
"order_tax_amount" => 2000,
"order_lines" => [
$cartsql="select a, b, c, d from lux_cart WHERE status = 0 ORDER BY a DESC";
if ($result=mysqli_query($mysqli,$cartsql)){
while ($cartrow=mysqli_fetch_row($result)){
$itemid = $cartrow[0];
$prodTitel = $cartrow[1];
$antalcart = $cartrow[2];
$prodPris = $cartrow[3];
[
"type" => "physical",
"reference" => "$itemid",
"name" => "$prodTitel",
"quantity" => $antalcart,
"unit_price" => $prodPris,
"tax_rate" => 2500,
"total_amount" => $prodPris,
"total_tax_amount" => 1200
],
}
}
"merchant_urls" => [
"terms" => "https://www.example.com/villkor.php",
"cancellation_terms" => "https://www.example.com/terms/cancellation.html",
"checkout" => "https://www.example.com/_script/checkout.php",
"confirmation" => "https://www.example.com/_script/checkout.php",
// Callbacks
"push" => "https://www.example.com/api/push",
"validation" => "https://www.example.com/api/validation",
"shipping_option_update" => "https://www.example.com/api/shipment",
"address_update" => "https://www.example.com/api/address",
"notification" => "https://www.example.com/api/pending",
"country_change" => "https://www.example.com/api/country"
]
];
But the page broken without any error message. I think I need to make some array ore something to resolve this issue. Can someone help me figure out what I am doing wrong here?
You can't execute PHP code inside an array definition like that. That's causing a parse error that's the reason your page is broken with no error. (You can change settings on your development server to show these errors as well.) Instead, define the array with an empty array for order_lines
$order = [
"purchase_country" => "SE",
"purchase_currency" => "SEK",
"locale" => "sv-SE",
"order_amount" => 10000,
"order_tax_amount" => 2000,
"order_lines" => [],
"merchant_urls" => [
"terms" => "https://www.example.com/villkor.php",
"cancellation_terms" => "https://www.example.com/terms/cancellation.html",
"checkout" => "https://www.example.com/_script/checkout.php",
"confirmation" => "https://www.example.com/_script/checkout.php",
// Callbacks
"push" => "https://www.example.com/api/push",
"validation" => "https://www.example.com/api/validation",
"shipping_option_update" => "https://www.example.com/api/shipment",
"address_update" => "https://www.example.com/api/address",
"notification" => "https://www.example.com/api/pending",
"country_change" => "https://www.example.com/api/country"
]
];
Then fill that key with values from your query.
$cartsql="select a, b, c, d from lux_cart WHERE status = 0 ORDER BY a DESC";
if ($result=mysqli_query($mysqli,$cartsql)){
while ($cartrow=mysqli_fetch_row($result)){
$itemid = $cartrow[0];
$prodTitel = $cartrow[1];
$antalcart = $cartrow[2];
$prodPris = $cartrow[3];
// Use [] to append the rows to the existing key
$order['order_lines'][] = [
"type" => "physical",
"reference" => "$itemid",
"name" => "$prodTitel",
"quantity" => $antalcart,
"unit_price" => $prodPris,
"tax_rate" => 2500,
"total_amount" => $prodPris,
"total_tax_amount" => 1200
];
}
}
Related
I have data like this:
$movements = [
array(
"amount" => 100,
"type" => "expense",
"Dates" => "2020-01-01"
),
array(
"amount" => 100,
"type" => "income",
"Dates" => "2020-01-01"
),
array(
"amount" => 200,
"type" => "expense",
"Dates" => "2020-02-01"
),
array(
"amount" => 200,
"type" => "income",
"Dates" => "2020-02-01"
),
array(
"amount" => 300,
"type" => "income",
"Dates" => "2020-03-01"
),
array(
"amount" => 400,
"type" => "expense",
"Dates" => "2020-04-01"
),
array(
"amount" => 400,
"type" => "income",
"Dates" => "2020-04-01"
),
]
I want to separate it into 3 different arrays like so:
//This are my chart labels
$dates = ["2020-01-01","2020-02-01","2020-03-01"."2020-04-01"]
//This are my datapoints
$income = [100,200,300,400]
$expense = [100,200,0,400]
For the life of me i just cant seem to wrap my head around this today, I have tried doing loops and while/if using "array_colum()" but I cant get to add a 0 for the entry that does not have a matching date.
PS: I need the data in that format snice im charting it on chart.js within a Laravel view.
Any help is greatly appreciated.
$movements = [
[ 'amount' => 100, 'type' => 'expense', 'Dates' => '2020-01-01' ],
[ 'amount' => 100, 'type' => 'income', 'Dates' => '2020-01-01' ],
[ 'amount' => 200, 'type' => 'expense', 'Dates' => '2020-02-01' ],
[ 'amount' => 200, 'type' => 'income', 'Dates' => '2020-02-01' ],
[ 'amount' => 300, 'type' => 'income', 'Dates' => '2020-03-01' ],
[ 'amount' => 400, 'type' => 'expense', 'Dates' => '2020-04-01' ],
[ 'amount' => 400, 'type' => 'income', 'Dates' => '2020-04-01' ],
];
$dates = array_values(array_unique(array_column($movements, 'Dates')));
$income = [];
$expense = [];
foreach ($dates as $date) {
$item = array_values(array_filter($movements, fn($item) => $item['Dates'] === $date));
$amount1 = $item[0]['amount'];
$amount2 = count($item) === 2 ? $item[1]['amount'] : 0;
$expense[] = $item[0] === 'expense' ? $amount1 : $amount2;
$income[] = $item[0] === 'expense' ? $amount2 : $amount1;
}
print_r($dates);
print_r($income);
print_r($expense);
This will print:
Array
(
[0] => 2020-01-01
[1] => 2020-02-01
[2] => 2020-03-01
[3] => 2020-04-01
)
Array
(
[0] => 100
[1] => 200
[2] => 300
[3] => 400
)
Array
(
[0] => 100
[1] => 200
[2] => 0
[3] => 400
)
I have been trying to create a MediaConverter job using the latest AWS SDK for PHP (7.4.2) and I'm getting really stuck at creating the job settings correctly. I was wondering if anyone could look at this php code and tell me if I'm just completely on the wrong track. The response I'm getting is:
Error executing "CreateJob" on "https://asdf.mediaconvert.us-east-1.amazonaws.com/2017-08-29/jobs"; AWS HTTP error: Client error: POST https://asdf.mediaconvert.us-east-1.amazonaws.com/2017-08-29/jobs resulted in a 400 Bad Request response: { "errorType": "BadRequestException", "httpStatus" : 400, "requestId" : "388473f1-92af-4253-940c-00307b7c2a79", (truncated...) BadRequestException (client): The request could not be interpreted. - { "errorType": "BadRequestException", "httpStatus" : 400, "requestId" : "388473f1-92af-4253-940c-00307b7c2a79", "message" : "The request could not be interpreted.", "settingsValidationErrorsJsonBlob" : "" }
I actually copied the JSON for the settings directly out of MediaConvert, so I assume that my issue lies in trying to convert this into an object in PHP for the purposes of sending it to AWS. The settings below make it through the AWS SDK and up to the server, which I suppose is a good start. But I can't figure out what is wrong.
"OutputGroups" => [
[
"CustomName" => "Thumbnails",
"Name" => "File Group",
"Outputs" => [
"ContainerSettings" => [
"Container" => "RAW"
],
"VideoDescription" => [
"Width" => 1280,
"ScalingBehavior" => "DEFAULT",
"Height" => 720,
"TimecodeInsertion" => "DISABLED",
"AntiAlias" => "ENABLED",
"Sharpness" => 50,
"CodecSettings" => [
"Codec" => "FRAME_CAPTURE",
"FrameCaptureSettings" => [
"FramerateNumerator" => 30,
"FramerateDenominator" => 540,
"MaxCaptures" => 18,
"Quality" => 70
]
],
"DropFrameTimecode" => "ENABLED",
"ColorMetadata" => "INSERT"
],
["Extension" => "jpg"],
["NameModifier" => "-thumb"]
],
"OutputGroupSettings" => [
"Type" => "FILE_GROUP_SETTINGS",
"FileGroupSettings" => [
"Destination" => "s3://me/my-folder/"
]
]
],
[
"CustomName" => "720p",
"Name" => "File Group",
"Outputs" => [
"ContainerSettings" => [
"Container" => "MP4",
"Mp4Settings" => [
"CslgAtom" => "INCLUDE",
"CttsVersion" => 0,
"FreeSpaceBox" => "EXCLUDE",
"MoovPlacement" => "PROGRESSIVE_DOWNLOAD"
]
],
"VideoDescription" => [
"Width" => 1280,
"ScalingBehavior" => "DEFAULT",
"Height" => 720,
"VideoPreprocessors" => [
"ImageInserter" => [
"InsertableImages" => [
"Width" => 200,
"Height" => 36,
"imageX" => 50,
"imageY" => 634,
"FadeIn" => 2000,
"Layer" => 2,
"ImageInserterInput" => "s3://me-again/My-Watermark.tga",
"StartTime" => "00:00:05;01",
"Opacity" => 50
]
]
],
"TimecodeInsertion" => "DISABLED",
"AntiAlias" => "ENABLED",
"Sharpness" => 50,
"CodecSettings" => [
"Codec" => "H_264",
"H264Settings" => [
"InterlaceMode" => "PROGRESSIVE",
"NumberReferenceFrames" => 3,
"Syntax" => "DEFAULT",
"Softness" => 0,
"GopClosedCadence" => 1,
"GopSize" => 90,
"Slices" => 1,
"GopBReference" => "DISABLED",
"SlowPal" => "DISABLED",
"SpatialAdaptiveQuantization" => "ENABLED",
"TemporalAdaptiveQuantization" => "ENABLED",
"FlickerAdaptiveQuantization" => "DISABLED",
"EntropyEncoding" => "CABAC",
"Bitrate" => 1800000,
"FramerateControl" => "INITIALIZE_FROM_SOURCE",
"RateControlMode" => "CBR",
"CodecProfile" => "MAIN",
"Telecine" => "NONE",
"MinIInterval" => 0,
"AdaptiveQuantization" => "HIGH",
"CodecLevel" => "AUTO",
"FieldEncoding" => "PAFF",
"SceneChangeDetect" => "ENABLED",
"QualityTuningLevel" => "SINGLE_PASS",
"FramerateConversionAlgorithm" => "DUPLICATE_DROP",
"UnregisteredSeiTimecode" => "DISABLED",
"GopSizeUnits" => "FRAMES",
"ParControl" => "INITIALIZE_FROM_SOURCE",
"NumberBFramesBetweenReferenceFrames" => 2,
"RepeatPps" => "DISABLED",
"DynamicSubGop" => "STATIC"
]
],
"AfdSignaling" => "NONE",
"DropFrameTimecode" => "ENABLED",
"RespondToAfd" => "NONE",
"ColorMetadata" => "INSERT"
],
"AudioDescriptions" => [
"AudioTypeControl" => "FOLLOW_INPUT",
"AudioSourceName" => "Audio Selector 1",
"CodecSettings" => [
"Codec" => "AAC",
"AacSettings" => [
"AudioDescriptionBroadcasterMix" => "NORMAL",
"Bitrate" => 96000,
"RateControlMode" => "CBR",
"CodecProfile" => "LC",
"CodingMode" => "CODING_MODE_2_0",
"RawFormat" => "NONE",
"SampleRate" => 48000,
"Specification" => "MPEG4"
]
],
"LanguageCodeControl" => "FOLLOW_INPUT"
],
["Extension" => "mp4"],
["NameModifier" => "-720p"]
],
"OutputGroupSettings" => [
"Type" => "FILE_GROUP_SETTINGS",
"FileGroupSettings" => [
"Destination" => "s3://me/my-folder"
]
]
]
],
"AdAvailOffset" => 0,
"Inputs" => [
[
"AudioSelectors" => [
"Audio Selector 1" => [
"Offset" => 0,
"DefaultSelection" => "DEFAULT",
"ProgramSelection" => 1
]
],
"FilterEnable" => "AUTO",
"PsiControl" => "USE_PSI",
"FilterStrength" => 0,
"DeblockFilter" => "DISABLED",
"DenoiseFilter" => "DISABLED",
"TimecodeSource" => "EMBEDDED",
"FileInput" => "s3://me-again/my-folder/my-video.mp4"
]
],
"AccelerationSettings" => [
"Mode" => "DISABLED"
],
"StatusUpdateInterval" => "SECONDS_60",
"Priority" => 0
];```
I solved this.
I took the JSON that I got from MediaConvert and then I created my PHP in five steps:
Replace all { with array(
Replace all : with =>
Replace all [ with array(
Replace all } with )
Replace all ] with )
After doing this it worked perfectly, first time.
I'm struggling to update a document and add new elements (fields) into it's existing array without losing the array elements on update.
This is my code which inserts a new document into the collection if it doesn't already exist (upsert):
$updateResult = $collection->findOneAndUpdate(
[
'recording-id' => $out['recording']->id
],
['$set' => [
'release' => [
'id' => $out['release']->id,
'title' => $out['release']->title,
'date' => $out['release']->date,
'country' => $out['release']->country
],
'artist' => [
'id' => $out['artist']->id,
'name' => $out['artist']->name,
],
'recording' => [
'id' => $out['recording']->id,
'title' => $out['recording']->title,
'score' => $out['recording']->score,
'length' => $out['recording']->length,
'release-count' => count($out['recording']->releases),
],
'release-group' => [
'id' => $out['release-group']['id'],
'title' => $out['release-group']['title'],
'first-release-date'=>$out['release-group']['first-release-date'],
'primary-type' => $out['release-group']['primary-type'],
'musicbrainz' => $out['release-group']['musicbrainz'],
'url-rels' => $out['release-group']['url-rels'],
'coverart' => $out['release-group']['coverart']
],
'execution' => [
'firstfind' => $out['execution']->time
]
]
],
['upsert' => true,
'projection' =>
[
'_id' => 0,
'release' => 1,
'artist' => 1,
'recording' => 1,
'release-group' => 1,
'execution' => 1
],
'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER,
]
);
So now I have an existing document in a collection:
{
"_id" : ObjectId("5d1a6aaf5ecc8001ee858f6c"),
"recording-id" : "d0d439f9-5324-4728-8706-2da39adb89c5",
"artist" : {
"id" : "9d97b077-b28d-4ba8-a3d9-c71926e3b2b6",
"name" : "Gordon Lightfoot"
},
"recording" : {
"id" : "d0d439f9-5324-4728-8706-2da39adb89c5",
"title" : "Sundown",
"score" : 100,
"length" : 184000,
"release-count" : 2
},
"release" : {
"id" : "0c008d76-2bc9-44a3-854b-0a08cde89337",
"title" : "All Live",
"date" : "2012-04-24",
"country" : "CA"
},
"release-group" : {
"id" : "0a5d5f33-8e9d-4fa4-b622-a95e4218a3c4",
"title" : "All Live",
"first-release-date" : "2012-04-24",
"primary-type" : "Album",
"musicbrainz" : "https://musicbrainz.org/release-group/0a5d5f33-8e9d-4fa4-b622-a95e4218a3c4",
"url-rels" : "https://musicbrainz.org/ws/2/release-group/0a5d5f33-8e9d-4fa4-b622-a95e4218a3c4?inc=url-rels&fmt=json",
"coverart" : null
}
}
Now, I would like to update this document, and add new fields into the arrays. The new fields are to be added to certain fields.
Here is the code doing that:
$collection = (new MongoDB\Client)->stream->musicbrainz;
$updateResult = $collection->updateOne(
[
'recording-id' => $out['recording']['id']
],
['$addToSet' => [
'artist' => [
'wikiQiD' => $out['artist']['qid'],
'wiki-extract' => $out['artist']['wiki-extract'],
'wiki-pageid' => $out['artist']['pageid'],
],
'release-group' => [
'wikiQiD' => $out['release-group']['qid'],
'wiki-extract' => $out['release-group']['wiki-extract']
]
]
],
[
'upsert' => true,
'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER,
]
);
I've noticed there's "$addToSet" and "$push" commands, and could use assistance with what the difference is between these two commands.
If the field is absent in the document to update, $push adds the array
field with the value as its element.
The $addToSet operator adds a value to an array unless the value is
already present, in which case $addToSet does nothing to that array.
I did some googling, and reading of the MongoDB/Client UpdateOne function, but can't seem to find a way to append these fields to the existing arrays.
The error I'm getting is:
Fatal error: Uncaught MongoDB\Driver\Exception\BulkWriteException: The field 'artist' must be an array but is of type object in document {_id: ObjectId('5d1a6aaf5ecc8001ee858f6c')} in ...
I know the following:
It could be my document, as it's not a proper array that Fatal error is complaining about.
It could be my `findOneAndUpdate' formatting, and I'm not doing that correctly.
It could be both and I have it all wrong from the very start.
Any insight or constructive criticism is appreciated, just refrain from flames, pls.
Here's the working code I finally use to get it do what I want it to.
It's a simple matter of just setting your field names and values and mongo will update the found record replacing it with the array sent to it. No need to push or anything.
function firstFindMongoUpdate($out) {
$collection = (new MongoDB\Client)->stream->musicbrainz;
$updateResult = $collection->findOneAndUpdate(
[
'recording-id' => $out['recording']->id
],
['$set' => [
'query' => $out['query'],
'release' => [
'id' => $out['release']->id,
'title' => $out['release']->title,
'date' => $out['release']->date,
'country' => $out['release']->country,
'label' => $out['release']->label,
],
'artist' => [
'id' => $out['artist']->id,
'name' => $out['artist']->name,
'wiki' => $out['artist']->wiki,
],
'recording' => [
'id' => $out['recording']->id,
'title' => $out['recording']->title, // sometimes contains apostophe ie; Bill‘s Love (option ] key)
'score' => $out['recording']->score,
'length' => $out['recording']->length,
'release-count' => count($out['recording']->releases)
],
'release-group' => [
'id' => $out['release-group']['id'],
'title' => $out['release-group']['title'],
'first-release-date'=>$out['release-group']['first-release-date'],
'primary-type' => $out['release-group']['primary-type'],
'musicbrainz' => $out['release-group']['musicbrainz'],
'url-rels' => $out['release-group']['url-rels'],
'coverart' => $out['release-group']['coverart'],
'wiki' => $out['release-group']['wiki']
],
'execution' => [
'artistQuery' => $out['execution']->artistQuery,
'recordingQuery'=> $out['execution']->recordingQuery,
'time' => $out['execution']->time
]
]
],
['upsert' => true,
'projection' =>
[
'_id' => 1,
'query' => 1,
'release' => 1,
'artist' => 1,
'recording' => 1,
'release-group' => 1,
'execution' => 1
],
'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER,
]
);
I am getting an error
I want to implement payment gateway but the error is much like :
Illegal string offset 'code'
Illegal string offset 'description'
'MercadoPagoException' with message 'transaction_amount attribute can't be null
This is my array
$preference_data = array(
"items" => array(
array(
"id" => "Code",
"title" => $rest['name'],
"currency_id" => "USD",
"picture_url" =>"https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
"description" => "Description",
"category_id" => "Category",
"quantity" => 1,
"unit_price" => intval($total_price)
)
),
"payer" => array(
"name" => "APRO".$a[0],
"surname" => $a[1],
"email" => "test_user_44825516#testuser.com",
"date_created" => "2014-07-28T09:50:37.521-04:00",
"phone" => array(
"area_code" => "11",
"number" => "4444-4444"
),
"identification" => array(
"type" => "DNI",
"number" => "12345678"
),
"address" => array(
"street_name" => "Street",
"street_number" => 123,
"zip_code" => "1430"
)
),
"back_urls" => array(
"success" => "http://localhost/duncan_fooddelivery/api/success.php",
"failure" => "http://www.failure.com",
"pending" => "http://www.pending.com"
),
"auto_return" => "approved",
"payment_methods" => array(
"excluded_payment_methods" => array(
array(
"id" => "amex",
)
),
"excluded_payment_types" => array(
array(
"id" => "ticket"
)
),
"installments" => 24,
"default_payment_method_id" => null,
"default_installments" => null,
),
"shipments" => array(
"receiver_address" => array(
"zip_code" => "1430",
"street_number"=> 123,
"street_name"=> "Street",
"floor"=> 4,
"apartment"=> "C"
)
),
"token" => array (
"card_id" => NULL,
"card_number_length" => 16,
"cardholder" => array (
"identification" => array (
"number" => "11111111",
"type" => "DNI",
),
"name" => "APROARPAN BAJPAI",
),
"creation_date" => NULL,
"due_date" => NULL,
"esc" => NULL,
"expiration_month" => 6,
"expiration_year" => 2022,
"first_six_digits" => "450995",
"id" => "ad56c2e6cb4a2b17c18e632139366a7e",
"last_four_digits" => "3704",
"last_modified_date" => NULL,
"luhn_validation" => "true",
"public_key" => "TEST-1a0ffe62-165f-4e7b-b501-df15741b6d87",
"security_code_length" => 3,
"status" => "active",
"trunc_card_number" => NULL,
"used_date" => NULL,
),
"transaction_amount" => 60,
"notification_url" => "https://www.your-site.com/ipn",
"external_reference" => "Reference_1234",
"expires" => false,
"expiration_date_from" => null,
"expiration_date_to" => null,
);
I am passing "transaction_amount" => 60, But still getting same error.
Please help me I am searching from 5 Hours.
Thanks.
I am trying to use ElasticTranscoderPHP to create a new preset with php, but I am getting the error "start of list found where not expected"
https://github.com/LPology/ElasticTranscoderPHP
What would cause this error?
$photo_info = getimagesize($_FILES["photo-file"]['tmp_name']);
$photo_width = $photo_info[0];
$photo_height = $photo_info[1];
$options = array(
"Name" => $vivaloo_id,
"Description" => "testing 123",
"Container" => "mp4",
"Audio" => array(
"Codec" => "AAC",
"CodecOptions" => array(
"Profile" => "AAC-LC"
),
"SampleRate" => "44100",
"BitRate" => "128",
"Channels" => "2",
),
"Video" => array(
"Codec" => "H.264",
"CodecOptions" => array(
"Profile" => "baseline",
"Level" => "3",
"MaxReferenceFrames" => "3"
),
"KeyframesMaxDist" => "90",
"FixedGOP" => "false",
"BitRate" => "600",
"FrameRate" => "29.97",
"MaxWidth" => $photo_width,
"MaxHeight" => $photo_height,
"SizingPolicy" => "Fill",
"PaddingPolicy" => "NoPad",
"DisplayAspectRatio" => "auto"
),
"Thumbnails" => array(
"Format" => "jpg",
"Interval" => "9999",
"MaxWidth" => "480",
"MaxHeight" => "480",
"SizingPolicy" => "Fit",
"PaddingPolicy" => "NoPad"
)
);
$presetResult = AWS_ET::createPreset( array($options) );
if (!$presetResult) {
echo AWS_ET::getErrorMsg();
}else{
echo 'New preset ID: ';
}
Answering my own question - hope it helps others...
I ultimately solved this issue by separating Audio, Video, and Thumbs settings into their own individual arrays. Here is an example:
//create a preset
$presetAudio = array(
"Codec" => "AAC",
"CodecOptions" => array( "Profile" => "AAC-LC"),
"SampleRate" => "32000",
"BitRate" => "64",
"Channels" => "2"
);
$presetVideo = array(
"Codec" => "H.264",
"CodecOptions" => array("Profile" => "baseline","Level" => "3","MaxReferenceFrames" => "3","BufferSize" => null, "MaxBitRate" => null),
"KeyframesMaxDist" => "90",
"FixedGOP" => "false",
"BitRate" => "500",
"FrameRate" => "29.97",
"MaxFrameRate" => null,
"MaxWidth" => "500", //note: MUST BE AN EVEN NUMBER
"MaxHeight" => "500", //note: MUST BE AN EVEN NUMBER
"SizingPolicy" => "Fill",
"PaddingPolicy" => "NoPad",
"DisplayAspectRatio" => "auto"
);
$presetThumbs = array(
"Format" => "jpg",
"Interval" => "9999",
"MaxWidth" => "100", //note: MUST BE AN EVEN NUMBER
"MaxHeight" => "100", //note: MUST BE AN EVEN NUMBER
"SizingPolicy" => "Fit",
"PaddingPolicy" => "NoPad"
);
$presetResult = AWS_ET::createPreset("name of preset", "description of preset", "mp4", $presetAudio, $presetVideo, $presetThumbs);
if (!$presetResult) {
echo AWS_ET::getErrorMsg();
} else {
$preset_id = $presetResult['Preset']['Id'];
echo $preset_id;
}