anilm Posted February 19, 2015 Share Posted February 19, 2015 I have an ebay script which I'm working on, but am not familiar with how to : call a couple of ebay arrays ($ship for shipping cost, and $cat1 for the product category), and a couple of other items ($condition to show if it is new,used etc, and $binauc to show if it is a buy it now or auction product) Any help would be appreciated. Here is the relevant part of the script: $country = isset($result['country'][0]) ? $result['country'][0] : ""; $condition = isset($result['condition'][0]) ? $result['condition'][0] : ""; $ship = sprintf("%01.2f", $result->shippingInfo->fshippingCost); $binauc = isset($result['listingInfo'][0]) ? $result['listingInfo'][0] : ""; $cat1 = sprintf($result->primaryCategory->categoryName); <div class="col-lg-3 thumbnail"><img class="img-responsive" src="'.$img.'"></div> <div class="col-lg-4 caption"><a target="_blank" href="'.$url.'"><h3>'.$title.'</h3></a></div> <div class="col-lg-2"><p class="lead">'.$price.'</p> <img style="width:30px;height:30px" src="images/flags/'.$country.'.png" /> '.$condition.' '.$ship.' '.$binauc.' '.$cat1.' </div> </div>'; Thanks Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/ Share on other sites More sharing options...
tryingtolearn Posted February 19, 2015 Share Posted February 19, 2015 Here is the relevant part of the script: Probably could use a bit more info What API are you using Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506133 Share on other sites More sharing options...
anilm Posted February 19, 2015 Author Share Posted February 19, 2015 Hi. Is this what you are referring to? http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=$your_ebay_app_id&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD&affiliate.networkId=9&affiliate.trackingId=$your_ebay_affiliate_tracking_id&affiliate.customId=$your_ebay_affiliate_custom_id&paginationInput.entriesPerPage=100&paginationInput.pageNumber=1&GLOBAL-ID=$eregion&keywords=".urlencode($keyword)); Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506143 Share on other sites More sharing options...
tryingtolearn Posted February 19, 2015 Share Posted February 19, 2015 Wanted to know if it was the finding API Is any part of your api call working? Do you get a response at all? Are you getting any values returned from what you posted above? If so which ones.. Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506145 Share on other sites More sharing options...
anilm Posted February 19, 2015 Author Share Posted February 19, 2015 Yes it is finding the API. I get the images, product descriptions, prices and locations. I'm just not sure what the format should be to call the condition, shipping costs, buy it now available, and product category Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506146 Share on other sites More sharing options...
tryingtolearn Posted February 19, 2015 Share Posted February 19, 2015 Here is a stab in the dark not seeing your code You can try: For condition use $cond = $result->condition->conditionDisplayName; For shipping costs use $ship = sprintf("%01.2f", $result->shippingInfo->shippingServiceCost); For buy it now available use $bina = $result->listingInfo->buyItNowAvailable; For product category use $category = $result->primaryCategory->categoryName; Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506150 Share on other sites More sharing options...
anilm Posted February 19, 2015 Author Share Posted February 19, 2015 Thanks, but they didn't work either. Here's everything from that page <div class="container"> <div class="col-lg-3"> </div> <div class="col-lg-9"> <div id="myTabs" class="tabbable"> <ul class="nav nav-tabs"> <li id="litabAll" class="active"><a title="All" id="atabAll">All</a></li> <li id="litab0"><a title="eBay" id="atab0">eBay</a></li> <li id="litab1"><a title="Amazon" id="atab1">Amazon</a></li> </ul> <div class="tab-content"> <div id="tab0" class="tab-pane active"> <div class="row"> <?php if($search != "" && $keyword != ""){ $econtent = file_get_contents("http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=$your_ebay_app_id&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD&affiliate.networkId=9&affiliate.trackingId=$your_ebay_affiliate_tracking_id&affiliate.customId=$your_ebay_affiliate_custom_id&paginationInput.entriesPerPage=100&paginationInput.pageNumber=1&GLOBAL-ID=$eregion&keywords=".urlencode($keyword)); $eresults = json_decode($econtent,true); foreach($eresults['findItemsByKeywordsResponse'][0]['searchResult'][0]['item'] as $result){ $title = isset($result['title'][0]) ? $result['title'][0] : ""; $img = isset($result['galleryURL'][0]) ? $result['galleryURL'][0] : ""; $url = isset($result['viewItemURL'][0]) ? $result['viewItemURL'][0] : ""; $price = isset($result['sellingStatus'][0]['currentPrice'][0]["__value__"]) ? $result['sellingStatus'][0]['currentPrice'][0]["__value__"]." ".$result['sellingStatus'][0]['currentPrice'][0]["@currencyId"] : ""; $country = isset($result['country'][0]) ? $result['country'][0] : ""; $condition = isset($result['condition'][0]) ? $result['condition'][0] : ""; $ship = sprintf("%01.2f", $result->shippingInfo->shippingServiceCost); $binauc = isset($result['listingInfo'][0]) ? $result['listingInfo'][0] : ""; $cat1 = isset($result['primaryCategory'][0]) ? $result['primaryCategory'][0] : ""; echo '<div class="row"> <div class="col-lg-3 thumbnail"><img class="img-responsive" src="'.$img.'"></div> <div class="col-lg-4 caption"><a target="_blank" href="'.$url.'"><h3>'.$title.'</h3></a></div> <div class="col-lg-2"> <img style="width:30px;height:30px" src="images/flags/'.$country.'.png" /> '.$condition.' '.$ship.' '.$binauc.' '.$cat1.' </div> <div class="col-lg-3"><p class="lead">'.$price.'</p></div> </div>'; } }else{ $econtent = file_get_contents("http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByCategory&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=$your_ebay_app_id&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD&affiliate.networkId=9&affiliate.trackingId=$your_ebay_affiliate_tracking_id&affiliate.customId=$your_ebay_affiliate_custom_id&paginationInput.entriesPerPage=100&paginationInput.pageNumber=1&GLOBAL-ID=$eregion&categoryId=".$ecat); $eresults = json_decode($econtent,true); $l = 0; foreach($eresults['findItemsByCategoryResponse'][0]['searchResult'][0]['item'] as $result){ $title = isset($result['title'][0]) ? $result['title'][0] : ""; $img = isset($result['galleryURL'][0]) ? $result['galleryURL'][0] : ""; $url = isset($result['viewItemURL'][0]) ? $result['viewItemURL'][0] : ""; $price = isset($result['sellingStatus'][0]['currentPrice'][0]["__value__"]) ? $result['sellingStatus'][0]['currentPrice'][0]["__value__"]." ".$result['sellingStatus'][0]['currentPrice'][0]["@currencyId"] : ""; $country = isset($result['country'][0]) ? $result['country'][0] : ""; $condition = isset($result['condition'][0]) ? $result['condition'][0] : ""; $ship = sprintf("%01.2f", $result->shippingInfo->shippingServiceCost); $binauc = isset($result['listingInfo'][0]) ? $result['listingInfo'][0] : ""; $cat1 = isset($result['primaryCategory'][0]) ? $result['primaryCategory'][0] : ""; echo '<div class="row"> <div class="col-lg-3 thumbnail"><img class="img-responsive" src="'.$img.'"></div> <div class="col-lg-4 caption"><a target="_blank" href="'.$url.'"><h3>'.$title.'</h3></a></div> <div class="col-lg-2"> <img style="width:30px;height:30px" src="images/flags/'.$country.'.png" /> '.$condition.' '.$ship.' '.$binauc.' '.$cat1.' </div> <div class="col-lg-3"><p class="lead">'.$price.'</p></div> </div>'; } } ?> </div> </div> <div id="tab1" class="tab-pane active"> <div class="row"> <?php if($search != "" && $keyword != ""){ for($i=1;$i<=5;$i++){ $params = array('Operation'=>"ItemSearch",'Service'=>"AWSECommerceService",'ItemPage'=>$i,'ResponseGroup'=>"Medium,OfferFull", 'SearchIndex'=>"All", 'Keywords'=>$keyword); $acontent = file_get_contents_curl(aws_signed_request($aregion, $params, YOUR_AWS_ACCESS_KEY_ID, YOUR_AWS_SECRET_ACCESS_KEY, YOUR_ASSOCIATE_TAG, $version='2011-08-01')); $xml = simplexml_load_string($acontent); $json = json_encode($xml); $aresults = json_decode($json,true); foreach ($aresults['Items']['Item'] as $result) { $url = $result['DetailPageURL']; $img = $result['MediumImage']['URL']; $lprice = $result['ItemAttributes']['ListPrice']['FormattedPrice']; $title = $result['ItemAttributes']['Title']; $offprice = $result['Offers']['Offer']['OfferListing']['Price']['FormattedPrice']; if($offprice == "") $price = $lprice; else $price = $offprice; echo '<div class="row"> <div class="col-lg-3 thumbnail"><img class="img-responsive" src="'.$img.'"></div> <div class="col-lg-4 caption"><a target="_blank" href="'.$url.'"><h3>'.$title.'</h3></a></div> <div class="col-lg-2"> </div> <div class="col-lg-3"><p class="lead">'.$price.'</p></div> </div>'; } if(!isset($aresults['Items']['Item'])) break; } }else{ for($i=1;$i<=5;$i++){ $params = array('Operation'=>"ItemSearch",'Service'=>"AWSECommerceService",'ItemPage'=>$i,'ResponseGroup'=>"Medium,OfferFull", 'SearchIndex'=>$aindex, 'BrowseNode'=>$acat); $acontent = file_get_contents_curl(aws_signed_request($aregion, $params, YOUR_AWS_ACCESS_KEY_ID, YOUR_AWS_SECRET_ACCESS_KEY, YOUR_ASSOCIATE_TAG, $version='2011-08-01')); $xml = simplexml_load_string($acontent); $json = json_encode($xml); $aresults = json_decode($json,true); foreach ($aresults['Items']['Item'] as $result) { $url = $result['DetailPageURL']; $img = $result['MediumImage']['URL']; $lprice = $result['ItemAttributes']['ListPrice']['FormattedPrice']; $title = $result['ItemAttributes']['Title']; $offprice = $result['Offers']['Offer']['OfferListing']['Price']['FormattedPrice']; if($offprice == "") $price = $lprice; else $price = $offprice; echo '<div class="row"> <div class="col-lg-3 thumbnail"><img class="img-responsive" src="'.$img.'"></div> <div class="col-lg-4 caption"><a target="_blank" href="'.$url.'"><h3>'.$title.'</h3></a></div> <div class="col-lg-2"> </div> <div class="col-lg-3"><p class="lead">'.$price.'</p></div> </div>'; } if(!isset($aresults['Items']['Item'])) break; } } ?> </div> </div> </div> </div> </div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506154 Share on other sites More sharing options...
Solution tryingtolearn Posted February 19, 2015 Solution Share Posted February 19, 2015 Hopefully this works better for you.. //condition, $condition = isset($result['condition'][0]['conditionDisplayName'][0]) ? $result['condition'][0]['conditionDisplayName'][0] : ""; //shipping costs, $ship = sprintf("%01.2f", $result['shippingInfo'][0]['shippingServiceCost'][0]["__value__"]); buy it now available, $binauc = isset($result['buyItNowAvailable'][0]) ? $result['buyItNowAvailable'][0] : ""; product category $cat1 = isset($result['primaryCategory'][0]['categoryName'][0]) ? $result['primaryCategory'][0]['categoryName'][0] : ""; Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506157 Share on other sites More sharing options...
anilm Posted February 19, 2015 Author Share Posted February 19, 2015 That's brilliant. Thanks so much for your time. Quote Link to comment https://forums.phpfreaks.com/topic/294723-help-with-ebay-call/#findComment-1506177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.