imper86/allegroapi

Not really an issue but need advice

Closed this issue · 3 comments

Hello I am tring to use your allegro API
Everything is working fine until i am trying to do DoCheckNewAuctionExtRequest

For after sales i do $afterSalesServiceConditions = new AfterSalesServiceConditionsStruct($impliedWarranties, $returnPolicies, $warranties);

But how to use $fields = new ArrayOfFieldsvalue($datafield_decoded);
What data and structure we should Put
$datafield_decoded = array(item_array("fid"=>1, ... ),item_array("fid"=>2, ... )) etc => return NULL

if I try to bypass the new ArrayOfFieldsvalue and put directly my $datafield_decoded on $fields place
i have error Fatal error: Uncaught SoapFault: Nie podano parametru wymaganego dla wybranej kategorii. (Kategoria - fid: 2) , FID 2 is well provided with int value...
Thanks for advice
And big thanks for this API :-)

Hello,

For ArrayOfFieldsvalue you should use collection of FieldsValue objects.
Unfortunately, PHP SoapClient has some limitations, so sending such big requests using these objects can end with fail.

I use simple array requests when using new auction methods. Allegro documentation shows how to do it: https://allegro.pl/webapi/documentation.php/show/id,41

HI
Many thank for your answer
I am not performing as you in PHP

So it is working like that

$param = json_decode( $datafield); //$datafields = AJAX POST of array(array("fid"=>xx, "fvalue"=>"", ect...))
$fields = new ArrayOfFieldsvalue();
$fields->setItem((array)$param);

this for the others newbies like me

BR

Yeah, good to know is that ArrayOfFieldsvalue implements ArrayAccess, so you can treat it like array. Eg. you can do it like that:

$fields = new ArrayOfFieldsvalue();
$fields[] = new FieldsValue();
$fields[] = new FieldsValue();