douyingmou1389 2014-11-12 15:51
浏览 48
已采纳

ebay api展示来自太平洋商店的商品

I am new to api's and ebays api. What i am trying to do is select items from a spacific store on ebay (http://stores.ebay.com/Nu-Tek-Sales : or userID : machinre_nuteksalesparts)

Currently it grabs 3 random items of off ebay. I think that I am using the wrong variable for the userID b/c if i set it to anything, I get the same results. Any help in the right direction would be nice. Thank you

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Merchandising Tutorial Sample</title>
<style type="text/css">body { font-family: arial,sans-serif; font-size: small; }     </style>
</head>
<body>
<?php
// Turn on all errors, warnings and notices for easier PHP debugging
error_reporting(E_ALL);

// Define global variables and settings
$m_endpoint = 'http://svcs.ebay.com/MerchandisingService?';  // Merchandising URL to call
$appid = 'My-account-ID';  // You will need to supply your own AppID
$responseEncoding = 'XML';  // Type of response we want back

// Create a function for the getMostWatchedItems call
function getMostWatchedItemsResults ($selectedItemID = '', $cellColor = '') {
global $m_endpoint;
global $appid;
global $responseEncoding;

// Construct getMostWatchedItems call with maxResults and categoryId as input
$apicalla  = "$m_endpoint";
$apicalla .= "OPERATION-NAME=getMostWatchedItems";
$apicalla .= "&SERVICE-VERSION=1.0.0";
$apicalla .= "&CONSUMER-ID=$appid";
$apicalla .= "&RESPONSE-DATA-FORMAT=$responseEncoding";
$apicalla .= "&maxResults=3";
$apicalla .= "&userID=machinre_nuteksalesparts";

// Load the call and capture the document returned by eBay API
$resp = simplexml_load_file($apicalla);

// Check to see if the response was loaded, else print an error
if ($resp) {
    // Set return value for the function to null
    $retna = '';

    // Verify whether call was successful
    if ($resp->ack == "Success") {

        // If there were no errors, build the return response for the function
        $retna .= "<h1>Top 3 Most Watched Items in the ";
        $retna .=  $resp->itemRecommendations->item->primaryCategoryName;
        $retna .= " Category</h1> 
";

        // Build a table for the 3 most watched items
        $retna .= "<!-- start table in getMostWatchedItemsResults --> 
";
        $retna .= "<table width=\"100%\" cellpadding=\"5\" border=\"0\"><tr> 
";

        // For each item node, build a table cell and append it to $retna
        foreach($resp->itemRecommendations->item as $item) {

            // Determine which price to display
            if ($item->currentPrice) {
                $price = $item->currentPrice;
            } else {
                $price = $item->buyItNowPrice;
            }

            // For each item, create a cell with imageURL, viewItemURL, watchCount, currentPrice
            $retna .= "<td valign=\"bottom\"> 
";
            $retna .= "<img src=\"$item->imageURL\"> 
";
            $retna .= "<p><a href=\"" . $item->viewItemURL . "\">" . $item->title . "</a></p>
";
            $retna .= 'Watch count: <b>' . $item->watchCount . "</b><br> 
";
            $retna .= 'Current price: <b>$' . $price . "</b><br><br> 
";
            $retna .= "</td> 
";
        }
        $retna .= "</tr></table> 
<!-- finish table in getMostWatchedItemsResults --> 
";

    } else {
        // If there were errors, print an error
        $retna = "The response contains errors<br>";
        $retna .= "Call used was: $apicalla";

    }  // if errors

} else {
    // If there was no response, print an error
    $retna = "Dang! Must not have got the getMostWatchedItems response!<br>";
    $retna .= "Call used was: $apicalla";
}  // End if response exists

// Return the function's value
return $retna;

} // End of getMostWatchedItemsResults function

// Display the response data
print getMostWatchedItemsResults('', '');

?>

</body>
</html>
  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮