server-webapi-code-09-addItem.php / php
<?php exit('FILL IN YOUR DEV TOKENS!'); appID = ''; token = ''; //api.sandbox.ebay.com/wsapi'; version = "405"; <?xml version=\"1.0\" encoding=\"utf-8\" ?> <request> <DetailLevel><![CDATA[1]]></DetailLevel> <SiteId><![CDATA[0]]></SiteId> <Verb><![CDATA[AddItem]]></Verb> <ErrorLevel><![CDATA[1]]></ErrorLevel> <RequestToken><![CDATA[token]]></RequestToken> <Country>US</Country> <Category>14111</Category> <Currency>1</Currency> <Description>This is the item description.</Description> <ListingDuration>Days_7</ListingDuration> <Location>San Jose, CA</Location> <PaymentMethods>PaymentSeeDescription</PaymentMethods> <PrimaryCategory> <CategoryID>357</CategoryID> </PrimaryCategory> <Quantity>1</Quantity> <RegionID>0</RegionID> <ReservePrice>5.0</ReservePrice> <StartPrice>1.0</StartPrice> <Title>Test Auction, TESTBAIT23</Title> <VisaMaster>1</VisaMaster> <SellerPays>0</SellerPays> <Version>2</Version> <Duration><![CDATA[5]]></Duration> <MinimumBid>1.00</MinimumBid> </request>"; // header("Content-Type: application/xml"); //request, 1, "AddItem"); //echo itemInfo = array(); addItem(itemInfo) { global itemInfo[] = array("DetailLevel" => "1"); itemInfo[] = array("Verb" => "AddItem"); itemInfo[] = array("RequestToken" => request = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; <request>\n"; foreach (itemInfo as value) { key}>{key}>\n"; } </request>"; } function sendRequest(request, callName) { global appID, token, requestLength = strlen(headers = array(); headers[] = "X-EBAY-API-SESSION-CERTIFICATE: appIDcert"; headers[] = "X-EBAY-API-DEV-NAME: headers[] = "X-EBAY-API-APP-NAME: headers[] = "X-EBAY-API-CERT-NAME: headers[] = "X-EBAY-API-CALL-NAME: headers[] = "X-EBAY-API-SITEID: 0"; detailLevel"; headers[] = "Content-Length: ch = curl_init(); curl_setopt(endPoint); curl_setopt(// Don't bother giving us the header back curl_setopt(ch, CURLOPT_HTTPHEADER, // Send our header curl_setopt(ch, CURLOPT_POST, true); // Send a POST curl_setopt(request); // This is the post to send curl_setopt(// Return the result, rather than printing it out data = curl_exec(ch); return
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.