I wrote a function to pull the ProductGroup from Amazon Web SErvices but I'm getting back the whole object.
function amazon($Access_Key,$Item_Id="B000VCKK02"){
$allparameter =
"Service" ."=". "AWSECommerceService" ."&".
"AWSAccessKeyId" ."=". $Access_Key ."&".
"Operation" ."=". "ItemLookup" ."&".
"IdType" ."-". "ASIN" ."&".
"ItemId" ."=". $Item_Id ."&".
"Version" ."=". "2009-01-06"
;
$request = file_get_contents("http://free.apisigning.com/onca/xml?".$allparameter);
$parsed_xml = simplexml_load_string($request);
// $parsed_xml['OperationRequest']->Items->Item->ItemAttributes->ProductGroup;
$parsed_xml->Items->Item->ItemAttributes->ProductGroup;
return $parsed_xml;
}
This is one object only. I passed in one ASIN (product number)
I guess I need an XML Editor to read the XML?
As far as I can tell it should be OperationRequest->Items->ItemAttributes->ProductGroup but nothing works.
I just need the PRoductGroup that is all.
See at the very bottom it says ProductGroup "Kitchen" that is all I need in a variable.
Thanks,
object(SimpleXMLElement)#1 (2) { ["OperationRequest"]=> object(SimpleXMLElement)#3 (3) { ["RequestId"]=> string(36) "0b149634-f02f-41a3-9f48-121e554b2884" ["Arguments"]=> object(SimpleXMLElement)#2 (1) { ["Argument"]=> array(8) { [0]=> object(SimpleXMLElement)#5 (1) { ["@attributes"]=> array(2) { ["Name"]=> string(9) "Operation" ["Value"]=> string(10) "ItemLookup" } } [1]=> object(SimpleXMLElement)#6 (1) { ["@attributes"]=> array(2) { ["Name"]=> string(7) "Service" ["Value"]=> string(19) "AWSECommerceService" } } [2]=> object(SimpleXMLElement)#7 (1) { ["@attributes"]=> array(2) { ["Name"]=> string(9) "Signature" ["Value"]=> string(44) "aHFTUdNDr0l8uwQfe+VuHMeFuD1JKwUgM9LrCqf4fLY=" } } [3]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(2) { ["Name"]=> string(7) "Version" ["Value"]=> string(10) "2009-01-06" } } [4]=> object(SimpleXMLElement)#9 (1) { ["@attributes"]=> array(2) { ["Name"]=> string(6) "ItemId" ["Value"]=> string(10) "B000VCKK02" } } [5]=> object(SimpleXMLElement)#10 (1) { ["@attributes"]=> array(1) { ["Name"]=> string(11) "IdType-ASIN" } } [6]=> object(SimpleXMLElement)#11 (1) { ["@attributes"]=> array(2) { ["Name"]=> string(14) "AWSAccessKeyId" ["Value"]=> string(20) "BLIJJJJLLLLIEOAKKLLLIIN" } } [7]=> object(SimpleXMLElement)#12 (1) { ["@attributes"]=> array(2) { ["Name"]=> string(9) "Timestamp" ["Value"]=> string(20) "2010-04-29T02:09:10Z" } } } } ["RequestProcessingTime"]=> string(18) "0.0194620000000000" } ["Items"]=> object(SimpleXMLElement)#4 (2) { ["Request"]=> object(SimpleXMLElement)#13 (2) { ["IsValid"]=> string(4) "True" ["ItemLookupRequest"]=> object(SimpleXMLElement)#15 (10) { ["Condition"]=> string(3) "New" ["DeliveryMethod"]=> string(4) "Ship" ["IdType"]=> string(4) "ASIN" ["MerchantId"]=> string(6) "Amazon" ["OfferPage"]=> string(1) "1" ["ItemId"]=> string(10) "B000VCKK02" ["ResponseGroup"]=> string(5) "Small" ["ReviewPage"]=> string(1) "1" ["ReviewSort"]=> string(15) "-SubmissionDate" ["VariationPage"]=> string(3) "All" } } ["Item"]=> object(SimpleXMLElement)#14 (4) { ["ASIN"]=> string(10) "B000VCKK02" ["DetailPageURL"]=> string(201) "http://www.amazon.com/HoMedics-Professional-Doctors-Scale/dp/B000VCKK02%3FSubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB000VCKK02" ["ItemLinks"]=> object(SimpleXMLElement)#16 (1) { ["ItemLink"]=> array(7) { [0]=> object(SimpleXMLElement)#18 (2) { ["Description"]=> string(17) "Technical Details" ["URL"]=> string(211) "http://www.amazon.com/HoMedics-Professional-Doctors-Scale/dp/tech-data/B000VCKK02%3FSubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02" } [1]=> object(SimpleXMLElement)#19 (2) { ["Description"]=> string(20) "Add To Baby Registry" ["URL"]=> string(204) "http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3DB000VCKK02%26SubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02" } [2]=> object(SimpleXMLElement)#20 (2) { ["Description"]=> string(23) "Add To Wedding Registry" ["URL"]=> string(207) "http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3DB000VCKK02%26SubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02" } [3]=> object(SimpleXMLElement)#21 (2) { ["Description"]=> string(15) "Add To Wishlist" ["URL"]=> string(208) "http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3DB000VCKK02%26SubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02" } [4]=> object(SimpleXMLElement)#22 (2) { ["Description"]=> string(13) "Tell A Friend" ["URL"]=> string(173) "http://www.amazon.com/gp/pdp/taf/B000VCKK02%3FSubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02" } [5]=> object(SimpleXMLElement)#23 (2) { ["Description"]=> string(20) "All Customer Reviews" ["URL"]=> string(177) "http://www.amazon.com/review/product/B000VCKK02%3FSubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02" } [6]=> object(SimpleXMLElement)#24 (2) { ["Description"]=> string(10) "All Offers" ["URL"]=> string(179) "http://www.amazon.com/gp/offer-listing/B000VCKK02%3FSubscriptionId%3DBLIJJJJLLLLIEOAKKLLLIIN%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02" } } } ["ItemAttributes"]=> object(SimpleXMLElement)#17 (3) { ["Manufacturer"]=> string(8) "Homedics" ["ProductGroup"]=> string(7) "Kitchen" ["Title"]=> string(26) "Professional Doctors Scale" } } } }