iT邦幫忙

DAY 28
1

[老鷹之且戰且飛]系列 第 28

[老鷹之且戰且飛]後續實例2(GetMyMessages)

這是訊息列表完全版

<?php
require_once('keys.php');
require_once('eBaySession.php');

//SiteID must also be set in the Request's XML
//SiteID = 0  (US) - UK = 3, Canada = 2, Australia = 15, ....
//SiteID Indicates the eBay site to associate the call with

$siteID = 0;

//the call being made:
$verb = 'GetMyMessages';
$startDate = date('Y-m-d',strtotime("-1 day")).'T00:00:01.000Z';

$requestXmlBody = <<<XML
<?xml version="1.0" encoding="utf-8" ?>
<GetMyMessagesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<StartTime>$startDate</StartTime>
<DetailLevel>ReturnHeaders</DetailLevel>
<RequesterCredentials>
<eBayAuthToken>$userToken</eBayAuthToken>
</RequesterCredentials>
<DetailLevel>ReturnHeaders</DetailLevel>
</GetMyMessagesRequest>
XML;

//Create a new eBay session with all details pulled in from included keys.php
$session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);

//send the request and get response
$responseXml = $session->sendHttpRequest($requestXmlBody);
if (stristr($responseXml, 'HTTP 404') || $responseXml == ''):
    die('<P>Error sending request');
endif;

$xml = simplexml_load_string($responseXml);
$count = count($xml->Messages->Message);
?>

    
        <title>取得訊息列表</title>
        <style>
            body{
                background-color: #999;
            }
            table{
                background-color: #000;
                color:#fff;
            }
        </style>
    
    
        <table style="width: 100%;">
            <tr>
                <th>ebay編號</th>
                <th>標題</th>
                <th>詳細</th>
            </tr>
            <?php for ($x = 0; $x < $count; $x++): ?>
                <tr>
                    <th><?= $xml->Messages->Message[$x]->ItemID; ?></th>
                    <th><?= $xml->Messages->Message[$x]->ItemTitle; ?></th>
                    <th><input type="button" value="詳細與回覆" onclick="window.location='message_content.php?id=<?= $xml->Messages->Message[$x]->MessageID; ?>'"</th>
                </tr>
            <?php endfor; ?>
        </table>
    

上一篇
[老鷹之且戰且飛]後續實例1(GetOrders)
下一篇
[老鷹之且戰且飛]後續實例3(GetMyMessages)
系列文
[老鷹之且戰且飛]30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言