Getting single Item Response From XmlToArray
BillDavid07 opened this issue · 1 comments
BillDavid07 commented
Hi, I am getting an error on retrieving the Title From amazon xml response. it said "Undefined index: Item" but when i dump the response it shows a string of data.
Here's the response
string(19) "George R. R. Martin" string(17) "Carol V Aebersold"
Whoops, looks like something went wrong.
1/1 ErrorException in AmazonController.php line 115: Undefined index: Item
Here's my Code
public function getAmazonFeed(){
$conf = new GenericConfiguration();
$client = new \GuzzleHttp\Client();
$request = new \ApaiIO\Request\GuzzleRequest($client);
$input = new Input();
$store_id = $input->get('s_id');
$shop = $input->get('shop');
$ssin = $input->get('ssin');
$querystrings = array('');
$itemlist = array();
$ilist = array('');
$message = '';
if(empty($shop)){
$status = false;
$message = 'Please select a source market';
}elseif(empty($ssin)){
$status = false;
$message = 'Products IDs is empty';
}elseif(empty($store_id)){
$status = false;
$message = 'Error on creating listings, can\'t find your store.';
}else{
$status = true;
try {
$conf
->setCountry($shop)
->setAccessKey(env('AMAZON_ACCESS_KEY'))
->setSecretKey(env('AMAZON_SECRET_KEY'))
->setAssociateTag(env('AMAZON_ASSOCIATE_TAG'))
->setRequest($request)
->setResponseTransformer(new \ApaiIO\ResponseTransformer\XmlToArray());
} catch (\Exception $e) {
echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$lookup = new Lookup();
$array_ssin = explode(',', $ssin);
$j = 0;
for ($i = 0; $i < count($array_ssin); $i++) {
$lookup->setItemId($array_ssin[$i]);
$lookup->setIdType('ASIN');
$lookup->setResponseGroup(array('Large', 'Small'));
$listing = $apaiIO->runOperation($lookup);
// $simpleXml = simplexml_load_string($listing);
var_dump($listing['Items']['Item']['ItemAttributes']['Author']);
// $itemlist[$i] = $ilist[$i]->Items;
}
}
echo json_encode(array(
'status' => $status,
'message' => $message,
'itemlist' => $itemlist
));
}
Thanks and Regards.
Jerome
BillDavid07 commented
Sorry its my fault. I already found the issue. :)