$client = new eBaySOAP($session); $PrimaryCategory = array('CategoryID' => 357); $Item = array('ListingType' => 'Chinese', 'Currency' => 'USD', 'Country' => 'US', 'PaymentMethods' => 'PaymentSeeDescription', 'RegionID' => 0, 'ListingDuration' => 'Days_3', 'Title' => 'The new item title', 'SubTitle' => 'The new item subtitle', 'Description' => "It's a great new item", 'Location' => "San Jose, CA", 'Quantity' => 1, 'StartPrice' => 24.99, 'BuyItNowPrice' => 54.99, 'PrimaryCategory' => $PrimaryCategory); $params = array('Version' => $compatibilityLevel, 'Item' => $Item); $results = $client->AddItem($params); $ItemID = (string) $results->ItemID; print "Listed Item ID: {$ItemID} <br>\n"; // Get it to confirm $params = array('Version' => $compatibilityLevel, 'ItemID' => $ItemID); $results = $client->GetItem($params); print "Got Item ID: {$ItemID} <br>\n"; print "It has a title of: " . $results->Item->Title . " <br>\n"; print "It has a BIN Price of: " . $results->Item->BuyItNowPrice->_ . ' ' . $results->Item->BuyItNowPrice->currencyID . " <br> \n"; // Revise it and change the Title and raise the BuyItNowPrice $Item = array('ItemID' => $ItemID, 'Title' => 'The revised item title', 'BuyItNowPrice' => 99.98999999999999); $params = array('Version' => $compatibilityLevel, 'Item' => $Item); $results = $client->ReviseItem($params); print "<hr>Revised Item ID: {$ItemID} <br>\n"; // Get it to confirm $params = array('Version' => $compatibilityLevel, 'ItemID' => $ItemID); $results = $client->GetItem($params); print "Got Item ID: {$ItemID} <br>\n"; print "It has a title of: " . $results->Item->Title . " <br>\n"; print "It has a BIN Price of: " . $results->Item->BuyItNowPrice->_ . ' ' . $results->Item->BuyItNowPrice->currencyID . " <br> \n"; } catch (SOAPFault $f) { print $f; // error handling } // Uncomment below to view SOAP envelopes // print "Request: \n".$client->__getLastRequest() ."\n"; // print "Response: \n".$client->__getLastResponse()."\n";
private function reviseItem($item) { $ShipToLocations = array(); $sql = "select id from site where name = '" . $item['Site'] . "'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $this->configEbay($row['id']); try { $client = new eBaySOAP($this->session); $Version = $this->version; $itemArray = array(); $itemArray['ConditionID'] = 1000; if (count($item['AttributeSetArray']) > 0) { $itemArray['AttributeSetArray'] = $item['AttributeSetArray']; } if (!empty($item['BuyItNowPrice']) && $item['BuyItNowPrice'] != 0 && $itemArray['BuyItNowPrice'] > $itemArray['StartPrice']) { $itemArray['BuyItNowPrice'] = $item['BuyItNowPrice']; } $itemArray['CategoryMappingAllowed'] = true; $itemArray['Country'] = $item['Country']; $itemArray['Currency'] = $item['Currency']; $itemArray['Description'] = $item['Description']; if (!empty($item['DispatchTimeMax'])) { $itemArray['DispatchTimeMax'] = $item['DispatchTimeMax']; } $itemArray['ItemID'] = $item['ItemID']; $itemArray['ListingDuration'] = $item['ListingDuration']; if ($item['BoldTitle'] == true) { $itemArray['ListingEnhancement'][] = "BoldTitle"; } if ($item['Border'] == true) { $itemArray['ListingEnhancement'][] = "Border"; } if ($item['Featured'] == true) { $itemArray['ListingEnhancement'][] = "Featured"; } if ($item['Highlight'] == true) { $itemArray['ListingEnhancement'][] = "Highlight"; } if ($item['HomePageFeatured'] == true) { $itemArray['ListingEnhancement'][] = "HomePageFeatured"; } $itemArray['ListingType'] = $item['ListingType']; if (!empty($item['Location'])) { $itemArray['Location'] = $item['Location']; } $itemArray['PaymentMethods'] = $item['PaymentMethods']; $itemArray['PayPalEmailAddress'] = $item['PayPalEmailAddress']; //PictureDetails if ($item['GalleryTypeFeatured']) { $itemArray['PictureDetails']['GalleryType'] = "Featured"; } if ($item['GalleryTypeGallery']) { $itemArray['PictureDetails']['GalleryType'] = "Gallery"; } if ($item['GalleryTypePlus']) { $itemArray['PictureDetails']['GalleryType'] = "Plus"; } if (!empty($item['GalleryURL'])) { $itemArray['PictureDetails']['GalleryURL'] = $item['GalleryURL']; } if (!empty($item['PictureURL']) && is_array($item['PictureURL'])) { $i = 0; foreach ($item['PictureURL'] as $p) { $itemArray['PictureDetails']['PictureURL'][$i] = $p; $i++; } } if (!empty($item['PostalCode'])) { $itemArray['PostalCode'] = $item['PostalCode']; } $itemArray['PrimaryCategory']['CategoryID'] = $item['PrimaryCategoryCategoryID']; if ($item['Site'] != "Germany") { $itemArray['PrivateListing'] = true; } $itemArray['Quantity'] = $item['Quantity']; if (!empty($item['ReturnPolicyReturnsAcceptedOption'])) { $itemArray['ReturnPolicy']['ReturnsAcceptedOption'] = $item['ReturnPolicyReturnsAcceptedOption']; if (!empty($item['ReturnPolicyDescription'])) { $itemArray['ReturnPolicy']['Description'] = $item['ReturnPolicyDescription']; } if (!empty($item['ReturnPolicyRefundOption'])) { $itemArray['ReturnPolicy']['RefundOption'] = $item['ReturnPolicyRefundOption']; } if (!empty($item['ReturnPolicyReturnsWithinOption'])) { $itemArray['ReturnPolicy']['ReturnsWithinOption'] = $item['ReturnPolicyReturnsWithinOption']; } if (!empty($item['ReturnPolicyShippingCostPaidByOption'])) { $itemArray['ReturnPolicy']['ShippingCostPaidByOption'] = $item['ReturnPolicyShippingCostPaidByOption']; } } if (!empty($item['SecondaryCategoryCategoryID'])) { $itemArray['SecondaryCategory']['CategoryID'] = $item['SecondaryCategoryCategoryID']; } if (!empty($item['InsuranceOption'])) { $itemArray['ShippingDetails']['InsuranceDetails']['InsuranceOption'] = $item['InsuranceOption']; $itemArray['ShippingDetails']['InsuranceDetails']['InsuranceFee'] = $item['InsuranceFee']; } if (!empty($item['InternationalInsurance'])) { $itemArray['ShippingDetails']['InternationalInsuranceDetails']['InsuranceOption'] = $item['InternationalInsurance']; $itemArray['ShippingDetails']['InternationalInsuranceDetails']['InsuranceFee'] = $item['InternationalInsuranceFee']; } $itemArray['ShippingDetails']['ShippingType'] = $item['ShippingType']; if (!empty($item['ShippingServiceOptions']) && is_array($item['ShippingServiceOptions'])) { $i = 0; foreach ($item['ShippingServiceOptions'] as $s) { $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['FreeShipping'] = $s['FreeShipping']; $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingService'] = $s['ShippingService']; $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingServiceCost'] = $s['ShippingServiceCost']; if (!empty($s['ShippingServiceAdditionalCost'])) { $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingServiceAdditionalCost'] = $s['ShippingServiceAdditionalCost']; } $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingServicePriority'] = $s['ShippingServicePriority']; $i++; } } if (!empty($item['InternationalShippingServiceOption']) && is_array($item['InternationalShippingServiceOption'])) { $j = 0; foreach ($item['InternationalShippingServiceOption'] as $i) { $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingService'] = $i['ShippingService']; $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingServiceCost'] = $i['ShippingServiceCost']; if (!empty($i['ShippingServiceAdditionalCost'])) { $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingServiceAdditionalCost'] = $i['ShippingServiceAdditionalCost']; } $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingServicePriority'] = $i['ShippingServicePriority']; if (!empty($i['ShipToLocation'])) { if (strpos($i['ShipToLocation'], ',') != false) { //echo "test1"; $stl_array = explode(',', $i['ShipToLocation']); foreach ($stl_array as $stl) { if (!in_array($stl, $ShipToLocations)) { array_push($ShipToLocations, $stl); } } //$ShipToLocations = array_merge($ShipToLocations, explode(',', $i['ShipToLocation'])); $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShipToLocation'] = explode(',', $i['ShipToLocation']); } else { //echo "test2"; if (!in_array($i['ShipToLocation'], $ShipToLocations)) { array_push($ShipToLocations, $i['ShipToLocation']); } $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShipToLocation'] = $i['ShipToLocation']; } } $j++; } } //print_r($itemArray['ShippingDetails']['InternationalShippingServiceOption']); //exit; //ShipToLocations /* switch($item['Site']){ case "US": $itemArray['ShipToLocations'] = "US"; break; case "UK": $itemArray['ShipToLocations'] = "GB"; break; case "Australia": $itemArray['ShipToLocations'] = "AU"; break; case "France": $itemArray['ShipToLocations'] = "Europe"; break; } */ //$itemArray['ShipToLocations'] = "Worldwide"; if (!empty($ShipToLocations)) { $itemArray['ShipToLocations'] = $ShipToLocations; } $itemArray['BuyerResponsibleForShipping'] = false; $itemArray['ShippingTermsInDescription'] = true; $itemArray['Site'] = $item['Site']; $itemArray['SKU'] = $item['SKU']; if (!empty($item['StartPrice']) && $item['StartPrice'] != 0) { $itemArray['StartPrice'] = $item['StartPrice']; } if (!empty($item['StoreCategoryID'])) { $itemArray['Storefront']['StoreCategoryID'] = $item['StoreCategoryID']; if (!empty($item['StoreCategory2ID'])) { $itemArray['Storefront']['StoreCategory2ID'] = $item['StoreCategory2ID']; } else { $itemArray['Storefront']['StoreCategory2ID'] = 0; } } if (!empty($item['SubTitle'])) { $itemArray['SubTitle'] = $item['SubTitle']; } $itemArray['Title'] = $item['Title']; //print_r($itemArray); //exit; $params = array('Version' => $Version, 'Item' => $itemArray); $results = $client->ReviseItem($params); //print_r($results); if (!empty($results->Errors)) { //$sql_0 = "update items set Status = 3 where Id = '".$item['Id']."'"; //$result_0 = mysql_query($sql_0); $this->parseEbayResponse("revise", $item, $results); if (!empty($results->ItemID)) { $sql = "update items set Status='2' where Id = '" . $item['Id'] . "'"; echo $sql; $result = mysql_query($sql); $this->log("revise", $item['Id'] . " revise success, ItemID is " . $results->ItemID); } } elseif (!empty($results->ItemID)) { $sql = "update items set Status='2' where Id = '" . $item['Id'] . "'"; echo $sql; $result = mysql_query($sql); $this->log("revise", $item['Id'] . " revise success, ItemID is " . $results->ItemID); } if (!empty($results->faultcode)) { //$sql_0 = "update items set Status = 3 where Id = '".$item['Id']."'"; //$result_0 = mysql_query($sql_0); $this->log("revise", $item['Id'] . " " . $results->faultcode . ": " . $results->faultstring, "error"); } //---------- debug -------------------------------- //print "Request: \n".$client->__getLastRequest() ."\n"; //print "Response: \n".$client->__getLastResponse()."\n"; //$this->saveFetchData("addItem-Request-".date("YmdHis").".html", print_r($results, true)); $this->saveFetchData("reviseItem-Request-" . date("YmdHis") . ".xml", $client->__getLastRequest()); $this->saveFetchData("reviseItem-Response-" . date("YmdHis") . ".xml", $client->__getLastResponse()); } catch (SOAPFault $f) { print $f; // error handling } }