SOAP-ERROR: Encoding: object has no 'verify_bool' property - php

After updating my SSL certificate Letsencrypt on server (Linux Ubuntu), I am getting error "SOAP-ERROR: Encoding: object has no 'verify_bool' property" when sending SOAP request. I am using SoapClient.php in Laravel application. Before updating the certificate it worked fine.
My code is here:
$soap_client = new \SoapClient("https://.....?WSDL", array(
'local_cert' => app_path('Services/my.pem'),
'passphrase' => 'mypasphrase')
);
$auth = $soap_client->AuthenticateUser(array(
'aName' => '777.SSL.888',
'aPassword' => 'password'
));
$session_id = $auth->AuthenticateUserResult->SessionID;
$data = $soap_client->getClientsByKeyFields(array(
'aSessionID' => $session_id,
'aClient' => array(
'ID' => 0,
'Natural_Person_Bool' => 1,
'Class_ID' => 10,
'Sex_ID' => 0,
'SETTLEMENT_ID' => 0,
'DOCUMENT_TYPE_ID' => 0,
'ACTIVITY_KIND_ID' => 0,
'RESIDENT_BOOL' => 1,
'ECONOMICS_SECTOR_ID' => 0,
'COUNTRY_ID' => 0,
'IIN' => $iin)
));

Solution was simple. I just needed to add "verify_bool" item to the array for 'aClient' in "getClientsByKeyFields()" function with default value, so my edited code for $data is
$data = $soap_client->getClientsByKeyFields(array(
'aSessionID' => $session_id,
'aClient' => array(
'ID' => 0,
'Natural_Person_Bool' => 1,
'Class_ID' => 10,
'Sex_ID' => 0,
'SETTLEMENT_ID' => 0,
'DOCUMENT_TYPE_ID' => 0,
'ACTIVITY_KIND_ID' => 0,
'RESIDENT_BOOL' => 1,
'ECONOMICS_SECTOR_ID' => 0,
'COUNTRY_ID' => 0,
'IIN' => $iin,
'verify_bool' => 1)
));

Related

Is there a chance that array_slice is bugged - returning wrong

Is there a chance to array_slice is bugged (using PHP 8.0.12)
I were looking for best way to get few elements(limited) of array with possible offset so tried to array_slice but its keep return me wrong index then i expect
I have array with objects from database and they looks like(ill write only id)
$questions simplified to only id
$limit = 1;
$questions = array(
array(
'id' => 2,
'stage' => 1,
'question_order' => 0,
'many_answers' => 0,
'points' => 5.5,
'spread_points_in_time' => 0,
'question' => "Czy Johnny Deep grał Jack'a Sparow'a?",
'time' => "00:00:10"
),
array(
'id' => 3,
'stage' => 1,
'question_order' => 0,
'many_answers' => 0,
'points' => 4.5,
'spread_points_in_time' =>0,
'question' => "Producent laptopa Darka",
'time' => "00:00:00"
),
array(
'id' => 1,
'stage' => 1,
'question_order' => 0,
'many_answers' => 0,
'points' => 10,
'spread_points_in_time' => 0,
'question' => "Która klawiatura jest mechniczna",
'time' => "00:00:10"
),
array(
'id' => 8,
'stage' => 2,
'question_order' => 0,
'many_answers' => 0,
'points' => 30,
'spread_points_in_time' => 1,
'question' => "2*2",
'time' => "00:00:30"
),
array(
'id' => 4,
'stage' => 2,
'question_order' => 0,
'many_answers' => 0,
'points' => 30,
'spread_points_in_time' => 0,
'question' => "Który język programowania ma dostęp do komórek pamięci komputera?",
'time' => "00:00:30"
),
array(
'id' => 7,
'stage' => 2,
'question_order' => 0,
'many_answers' => 0,
'points' => 30,
'spread_points_in_time' => 0,
'question' => "2+2",
'time' => "00:00:30"
),
array(
'id' => 10,
'stage' => 3,
'question_order' => 1,
'many_answers' => 1,
'points' => 5,
'spread_points_in_time' => 0,
'question' => "Jaki jest symbol chemiczny srebra?",
'time' => "00:00:00"
),
array(
'id' => 11,
'stage' => 3,
'question_order' => 0,
'many_answers' => 1,
'points' => 5,
'spread_points_in_time' => 0,
'question' => "Jaka jest żywotność ważki?",
'time' => "00:00:00"
),
array(
'id' => 9,
'stage' => 3,
'question_order' => 0,
'many_answers' => 0,
'points' => 5,
'spread_points_in_time' => 0,
'question' => "W którym roku Titanic zatonął na Oceanie Atlantyckim 15 kwietnia podczas dziewiczej podróży z Southampton?",
'time' => "00:00:00"
)
);
echo json_encode(
array(
'all' => $questions,
'limit' => $limit,
'sliced' => array_slice($questions, 0, $limit),
)
);
so when i try array_splice(array, 0, 1) i would expect 1 so id should be 2 but instead i get object which have id 1
i also tried with flag to keep indexed but then i end up same but with true index of object with id 1 (then key is 2)
If i put limit as 2 then i get object with id 1 and also object with id 2 (flag to keep indexed also return me properly to objects 2 and 0)
Also tried to remove id from every object by
foreach($questions as $key => $question)
{
unset($questions[$key]['id'];
}
But this didnt changed anything
$questions source https://pastebin.com/wDfJdm9Z
After plenty of combinations i figured it out
I were sorting this array before everything with forcing keys
So in sorting it looked like
foreach($toSort as $key => $item)
{
foreach($ids as $idKey => $id)
{
if($item['id'] == $id)
{
$sorted[$idKey] = $item;
break;
}
}
}
So for example array could end up with wrong order of keys like:
array(
[1] => item2,
[0] => item1,
[2] => item3
);
I were expecting array gona shove key 0 to be index 0 but don't looks like
Setting something to exact key isn't same as set something to set at exact index
SOLUTION WAS add ksort($sorted) before return $sorted

exif_read_data on PHP 7.2 doesn't return all metadata

On PHP 7.2, the built-in function exif_read_data returns different information to PHP 7.1
This is what I get when I use 7.2:
php -r 'var_export(exif_read_data("x.jpg", "ANY_TAG"));'
array (
'FileName' => 'x.jpg',
'FileDateTime' => 1543144462,
'FileSize' => 3564506,
'FileType' => 2,
'MimeType' => 'image/jpeg',
'SectionsFound' => 'ANY_TAG, IFD0, EXIF',
'COMPUTED' =>
array (
'html' => 'width="3968" height="2976"',
'Height' => 2976,
'Width' => 3968,
'IsColor' => 1,
'ByteOrderMotorola' => 1,
),
'ImageWidth' => 3968,
'ImageLength' => 2976,
'BitsPerSample' =>
array (
0 => 8,
1 => 8,
2 => 8,
),
'ImageDescription' => 'ptr',
'Make' => 'HUAWEI',
'Model' => 'STF-L09',
'Orientation' => 0,
'XResolution' => '72/1',
'YResolution' => '72/1',
'ResolutionUnit' => 2,
'Software' => 'STF-L09C432B120',
'DateTime' => '2018:11:24 15:11:58',
'YCbCrPositioning' => 1,
)
But when I run the exact same code on 7.1, I get much more EXIF data:
array (
'FileName' => 'x.jpg',
'FileDateTime' => 1543144462,
'FileSize' => 3564506,
'FileType' => 2,
'MimeType' => 'image/jpeg',
'SectionsFound' => 'ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP',
'COMPUTED' =>
array (
'html' => 'width="3968" height="2976"',
'Height' => 2976,
'Width' => 3968,
'IsColor' => 1,
'ByteOrderMotorola' => 1,
'ApertureFNumber' => 'f/2.2',
'Thumbnail.FileType' => 2,
'Thumbnail.MimeType' => 'image/jpeg',
'Thumbnail.Height' => 384,
'Thumbnail.Width' => 512,
),
'ImageWidth' => 3968,
'ImageLength' => 2976,
'BitsPerSample' =>
array (
0 => 8,
1 => 8,
2 => 8,
),
'ImageDescription' => 'ptr',
'Make' => 'HUAWEI',
'Model' => 'STF-L09',
'Orientation' => 0,
'XResolution' => '72/1',
'YResolution' => '72/1',
'ResolutionUnit' => 2,
'Software' => 'STF-L09C432B120',
'DateTime' => '2018:11:24 15:11:58',
'YCbCrPositioning' => 1,
'Exif_IFD_Pointer' => 280,
'GPS_IFD_Pointer' => 8454,
'DeviceSettingDescription' => 'ipp' . "\0" . '',
'THUMBNAIL' =>
array (
'ImageWidth' => 512,
'ImageLength' => 384,
'Compression' => 6,
'Orientation' => 0,
'XResolution' => '72/1',
'YResolution' => '72/1',
'ResolutionUnit' => 2,
'JPEGInterchangeFormat' => 8802,
'JPEGInterchangeFormatLength' => 31647,
),
'DocumentName' => NULL,
'ExposureTime' => '30000000/1000000000',
'FNumber' => '220/100',
'ExposureProgram' => 2,
'ISOSpeedRatings' => 320,
'ExifVersion' => '0210',
'DateTimeOriginal' => '2018:11:24 15:11:58',
'DateTimeDigitized' => '2018:11:24 15:11:58',
'ComponentsConfiguration' => '' . "\0" . '',
'ShutterSpeedValue' => '298973/10000',
'ApertureValue' => '227/100',
'BrightnessValue' => '0/1',
'ExposureBiasValue' => '0/10',
'MeteringMode' => 5,
'LightSource' => 1,
'Flash' => 0,
'FocalLength' => '3950/1000',
'MakerNote' => 'Auto',
'SubSecTime' => '405238',
'SubSecTimeOriginal' => '405238',
'SubSecTimeDigitized' => '405238',
'FlashPixVersion' => '0100',
'ColorSpace' => 1,
'ExifImageWidth' => 3968,
'ExifImageLength' => 2976,
'InteroperabilityOffset' => 8424,
'SensingMethod' => 2,
'FileSource' => '',
'SceneType' => '',
'CustomRendered' => 1,
'ExposureMode' => 0,
'WhiteBalance' => 0,
'DigitalZoomRatio' => '100/100',
'FocalLengthIn35mmFilm' => 27,
'SceneCaptureType' => 0,
'GainControl' => 0,
'Contrast' => 0,
'Saturation' => 0,
'Sharpness' => 0,
'SubjectDistanceRange' => 0,
'GPSVersion' => '' . "\0" . '' . "\0" . '',
'GPSLatitudeRef' => 'N',
'GPSLatitude' =>
array (
0 => '51/1',
1 => '8/1',
2 => '49994201/1000000',
),
'GPSLongitudeRef' => 'W',
'GPSLongitude' =>
array (
0 => '2/1',
1 => '42/1',
2 => '59101467/1000000',
),
'GPSAltitudeRef' => '' . "\0" . '',
'GPSAltitude' => '7162/100',
'GPSTimeStamp' =>
array (
0 => '15/1',
1 => '11/1',
2 => '58/1',
),
'GPSProcessingMode' => 'GPS' . "\0" . '',
'GPSDateStamp' => '2018:11:24',
'InterOperabilityIndex' => 'R98',
'InterOperabilityVersion' => '0100',
)
Are there any modules or extensions or changes that I can make to get the full EXIF data when using 7.2? I'm on a shared Linux host, so have some limitations on what I can do.
This appears to be a bug in PHP - https://bugs.php.net/bug.php?id=72682 and https://abi-laboratory.pro/index.php?view=changelog&l=php&v=7.2.3
The only answer is to downgrade - or upgrade - to a version which doesn't have the bug.

Assign an array in an array variable in PHP

I want to assign an array as an value of another variable in PHP. First array is
<?php
$jsonData = array(
'EndUserIp' => $ipAddress,
'TokenId' => 'a58c1052-c08f-4f40-9a9c-8841de585a14',
'AdultCount' => 1,
'ChildCount' => 0,
'InfantCount' => 0,
'DirectFlight' => 1,
'OneStopFlight' => 0,
'JourneyType' => 1,
'Segments'
);
?>
The second array is:
<?php
$segmentVal = array(
'Origin' => 'DEL',
'Destination' => 'CCU',
'FlightCabinClass' => 2,
'PreferredDepartureTime' => '2017-10-13T00:00:00',
'PreferredArrivalTime' => '2017-10-13T00:00:00'
);
?>
I want to assign the second array as the value of Segment variable in the first array.
try $jsonData['Segments'] = $segmentVal;
Following way to do array combine.
1)
<?php
$segmentVal = array(
'Origin' => 'DEL',
'Destination' => 'CCU',
'FlightCabinClass' => 2,
'PreferredDepartureTime' => '2017-10-13T00:00:00',
'PreferredArrivalTime' => '2017-10-13T00:00:00'
);
$jsonData = array(
'EndUserIp' => $ipAddress,
'TokenId' => 'a58c1052-c08f-4f40-9a9c-8841de585a14',
'AdultCount' => 1,
'ChildCount' => 0,
'InfantCount' => 0,
'DirectFlight' => 1,
'OneStopFlight' => 0,
'JourneyType' => 1,
'Segments' => $segmentVal
);
?>
2)
<?php
$jsonData = array(
'EndUserIp' => $ipAddress,
'TokenId' => 'a58c1052-c08f-4f40-9a9c-8841de585a14',
'AdultCount' => 1,
'ChildCount' => 0,
'InfantCount' => 0,
'DirectFlight' => 1,
'OneStopFlight' => 0,
'JourneyType' => 1,
'Segments' => array(
'Origin' => 'DEL',
'Destination' => 'CCU',
'FlightCabinClass' => 2,
'PreferredDepartureTime' => '2017-10-13T00:00:00',
'PreferredArrivalTime' => '2017-10-13T00:00:00'
)
);
?>
I came up with two possible ways to do so
First one is passing encoding the second array with json as below
$jsonData = array(
'EndUserIp' => "192.168.0.10",
'TokenId' => 'a58c1052-c08f-4f40-9a9c-8841de585a14',
'AdultCount' => 1,
'ChildCount' => 0,
'InfantCount' => 0,
'DirectFlight' => 1,
'OneStopFlight' => 0,
'JourneyType' => 1,
'Segments' => json_encode($segmentVal),
);
The second one is similar
You can serialize the $segmentVal as below
$jsonData = array(
'EndUserIp' => "192.168.0.10",
'TokenId' => 'a58c1052-c08f-4f40-9a9c-8841de585a14',
'AdultCount' => 1,
'ChildCount' => 0,
'InfantCount' => 0,
'DirectFlight' => 1,
'OneStopFlight' => 0,
'JourneyType' => 1,
'Segments' => serialize($segmentVal),
);

Create a new DropDown (select) product attribute (with options) in magento via SOAP API v1

I am trying to create a global product attribute that is used for configurable product.
This is how I would do it using the admin backend:
With the following options (for example):
So, I tried to do the above using the SOAP API (v1) like this:
$client = new SoapClient('http://domain.com/api/soap?wsdl');
$session = $client->login('apiUser', 'apiPass');
$attributeData = [
'attribute_code' => 'test',
'scope' => 'global',
'frontend_input' => 'select',
'options' => [
'values' => [
0 => 'Red',
1 => 'Green',
2 => 'Blue'
]
],
'default_value' => '',
'is_configurable' => 1,
'used_in_product_listing' => 1,
'is_visible_on_front' => 0,
'apply_to' => '',
'is_comparable' => 0,
'is_used_for_promo_rules' => 0,
'is_required' => 0,
'is_unique' => 0,
'is_searchable' => 0,
'is_visible_in_advanced_search' => 0,
'frontend_label' => [[
'store_id' => 0,
'label' => 'Test'
]]
];
try
{
$result = $client->call($session, 'product_attribute.create', $attributeData);
var_dump($result);
}
catch (SoapFault $sf)
{
var_dump($sf);
}
$client->endSession($session);
When I execute this script, I get the following error:
Invalid request parameters.
Any ideas what I am doing wrong here?
Here is the sample code. You may try.
<?php
$user = 'user';
$password = '123456789';
$client = new SoapClient('http://domain.com/api/soap/?wsdl');
$session = $client->login($user, $password);
// Create new attribute
$attributeToCreate = array(
"attribute_code" => "test_attribute",
"scope" => "global",
"frontend_input" => "select",
"is_unique" => 0,
"is_required" => 0,
"is_configurable" => 1,
"is_searchable" => 0,
"is_visible_in_advanced_search" => 0,
"used_in_product_listing" => 0,
"additional_fields" => array(
"is_filterable" => 1,
"is_filterable_in_search" => 1,
"position" => 1,
"used_for_sort_by" => 1
),
"frontend_label" => array(
array(
"store_id" => 0,
"label" => "A test attribute"
)
)
);
$attributeId = $client->call(
$session,
"product_attribute.create",
array(
$attributeToCreate
)
);
// add options
$attributeCode = $attributeToCreate['attribute_code'];
$selectOptions = array('Value 1','Value 2','Value 3','Value 4');
foreach ($selectOptions as $opt) {
$client->call(
$session,
"product_attribute.addOption",
array(
$attributeCode,
array(
"label" => array(
array(
"store_id" => 0,
"value" => $opt
)
),
"order" => 0,
"is_default" => 0
)
)
);
}
// add attribute to a attribute set
$setId = 4; //attribute set id
$result = $client->call(
$session,
"product_attribute_set.attributeAdd",
array(
$attributeId, // created attribute id
$setId
)
);
var_dump($attributeId);
$client->endSession($session);
?>

kashflow api script keeps failing to connect

The problem I have is with the script that connects to kashflow from our website, when a customer enters their order and finalises the checkout the site is supposed to connect to kashflow but instead gives the following error.
Notice: Undefined index: $Name in
/home/expressn/public_html/ajax/kashflow/includes/kashflow.inc.php on
line 73
Unhandled exception: Customer name cannot be empty
It's been narrowed down to the following code we hope as Customer Name is apparently a blank string?
Would anyone be kind enough to tell me what needs to be done to solve this problem?
public function insertCustomer($customer){
$parameters['custr'] = array(
"CustomerID" => 0,
"Code" => '',
"Name" => $customer['Name'],
"Contact" => '',
"Telephone" => $customer['Telephone'],
"Mobile" => '',
"Fax" => '',
"Email" => $customer['Email'],
"Address1" => $customer['Address1'],
"Address2" => $customer['Address2'],
"Address3" => $customer['Address3'],
"Address4" => $customer['Address4'],
"Postcode" => $customer['Postcode'],
"Website" => '',
"EC" => 0,
"OutsideEC" => 0,
"Notes" => '',
"Source" => $this->m_source,
"Discount" => 0,
"ShowDiscount" => 0,
"PaymentTerms" => 0,
"ExtraText1" => '',
"ExtraText2" => '',
"ExtraText3" => '',
"ExtraText4" => '',
"ExtraText5" => '',
"ExtraText6" => '',
"ExtraText7" => '',
"ExtraText8" => '',
"ExtraText9" => '',
"ExtraText10" => '',
"ExtraText11" => '',
"ExtraText12" => '',
"ExtraText13" => '',
"ExtraText14" => '',
"ExtraText15" => '',
"ExtraText16" => '',
"ExtraText17" => '',
"ExtraText18" => '',
"ExtraText19" => '',
"ExtraText20" => '',
"CheckBox1" => 0,
"CheckBox2" => 0,
"CheckBox3" => 0,
"CheckBox4" => 0,
"CheckBox5" => 0,
"CheckBox6" => 0,
"CheckBox7" => 0,
"CheckBox8" => 0,
"CheckBox9" => 0,
"CheckBox10" => 0,
"CheckBox11" => 0,
"CheckBox12" => 0,
"CheckBox13" => 0,
"CheckBox14" => 0,
"CheckBox15" => 0,
"CheckBox16" => 0,
"CheckBox17" => 0,
"CheckBox18" => 0,
"CheckBox19" => 0,
"CheckBox20" => 0,
"Created" => date( "Y-m-d\TH:i:s"),
"Updated" => date( "Y-m-d\TH:i:s"),
"CurrencyID" => 0,
"ContactTitle" => '',
"ContactFirstName" => '',
"ContactLastName" => '',
"CustHasDeliveryAddress" => 1,
"DeliveryAddress1" => $customer['delAddress1'],
"DeliveryAddress2" => $customer['delAddress2'],
"DeliveryAddress3" => $customer['delAddress3'],
"DeliveryAddress4" => $customer['delAddress4'],
"DeliveryPostcode" => $customer['delPostcode'],
"VATNumber" => ''
);
return $this->makeRequest("InsertCustomer",$parameters);
}
Hello I know it has been a while now but I also ran into this problem.
From my experience the mandatory params are:
'CustomerID'=>0,
'EC'=>0,
'OutsideEC'=>0,
'Source'=>0,
'Discount'=>0,
'ShowDiscount'=>0,
'PaymentTerms'=>0,
'CheckBox1'=>0,
'CheckBox2'=>0,
'CheckBox3'=>0,
'CheckBox4'=>0,
'CheckBox5'=>0,
'CheckBox6'=>0,
'CheckBox7'=>0,
'CheckBox8'=>0,
'CheckBox9'=>0,
'CheckBox10'=>0,
'CheckBox11'=>0,
'CheckBox12'=>0,
'CheckBox13'=>0,
'CheckBox14'=>0,
'CheckBox15'=>0,
'CheckBox16'=>0,
'CheckBox17'=>0,
'CheckBox18'=>0,
'CheckBox19'=>0,
'CheckBox20'=>0,
'Created'=> '',
'Updated'=>'',
'CurrencyID'=>0,
'Name'=>''
The case that you use for the keys is also important so "EC" is not the same as "ec". The api also returns a blank object if you are not authenticated, this can make it seem as if it is working when it is not.
So one thing to check is that you are giving 'UserName' & 'Password' not 'username' & 'password' just another thing is that I found https://securedwebapp.com/api/service.asmx << this doc is much better than http://www.kashflow.com/developers/soap-api/ << this doc for detailing how to call the APIs.

Categories