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条)

报告相同问题?

悬赏问题

  • ¥40 单片机实验录制讲解视频
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动
  • ¥15 大一C语言期末考试,求帮助🙏🙏
  • ¥15 ch340驱动未分配COM
  • ¥15 Converting circular structure to JSON
  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader
  • ¥45 谷歌浏览器出现开发者工具无法显示已创建的,但您可以调试已部署的代码。 状态代码 404, net::ERR HTTP RESPONSE CODE FAILURE
  • ¥15 如何解决蓝牙通话音频突发失真问题