Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package EbayLister.com;
- import java.awt.AWTException;
- import java.io.IOException;
- import java.util.Map;
- import java.util.TreeMap;
- import org.codehaus.jettison.json.JSONException;
- import org.jsoup.Connection.Method;
- import org.jsoup.Connection.Response;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.jsoup.nodes.Element;
- import org.jsoup.parser.Parser;
- import org.jsoup.select.Elements;
- import AmznTrackingPackage.AmznTrackingFunction;
- import EbayAssitivePackage.EbayApi;
- import EbayAssitivePackage.FixedPriceCalculation;
- import EbayTrackingPackage.EbayScrapeFunction;
- public class EbayLister {
- String amznAsin = "";
- String ackMessage = "Error";
- public String getAmznAsin() {
- return amznAsin;
- }
- public String listAmazonItem(String amazonUrl, String titleToPost) throws IOException, JSONException, InterruptedException, AWTException {
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Start]
- boolean posted = false;
- String ebayLink = null;
- AmznTrackingFunction amzn = new AmznTrackingFunction(amazonUrl);
- boolean search = amzn.search();
- amznAsin = amzn.getAmznAsin();
- if(amzn.isListingVero() == true)
- {
- System.out.println("--------------------ERROR----------------------------[START}\n" +
- "\n" +
- "\n" +
- "ITEM IS VERO PROTECTED: \n" +
- "\n" +
- "\n" +
- "\n" +
- "PLEASE ENTER VALID & UNPOSTED ITEM\n" +
- "\n" +
- "\n" +
- "\n" +
- "--------------------ERROR----------------------------[END]");
- }
- if(amzn.isItemOutOfStock() == true)
- {
- System.out.println("--------------------ERROR----------------------------[START}\n" +
- "\n" +
- "\n" +
- "ITEM IS OUT OF STOCK: \n" +
- "\n" +
- "\n" +
- "\n" +
- "PLEASE ENTER VALID & UNPOSTED ITEM\n" +
- "\n" +
- "\n" +
- "\n" +
- "--------------------ERROR----------------------------[END]");
- }
- boolean isItemVero = amzn.isListingVero();
- //isItemVero = false;
- if(search==true && isItemVero == false && amzn.isItemOutOfStock() == false) {
- //------------------------------------if(search==true) {-------------------------------***[Start]
- //System.out.println("starting Post");
- String input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
- "<AddFixedPriceItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n" +
- " <RequesterCredentials>\n" +
- " <eBayAuthToken>YOURTOKENHERE</eBayAuthToken>\n" +
- " </RequesterCredentials>\n" +
- " <ErrorLanguage>en_CA</ErrorLanguage>\n" +
- " <WarningLevel>High</WarningLevel>\n" +
- " <Item>\n" +
- " <AutoPay>true</AutoPay>"+
- " <UseTaxTable>true</UseTaxTable>\n" +
- " <Title>Apple MacBook Pro MB990LL/A 13.3 in. Notebook NEW</Title>\n" +
- " <Description>Brand New Apple MacBook Pro MB990LL/A 13.3 in. Notebook!</Description>\n" +
- " <PrimaryCategory>\n" +
- " <CategoryID>111422</CategoryID>\n" +
- " </PrimaryCategory>\n" +
- " <SKU> SKUType (string) </SKU>\n"+
- " <StartPrice>500.0</StartPrice>\n" +
- " <CategoryMappingAllowed>true</CategoryMappingAllowed>\n" +
- " <ConditionID>1000</ConditionID>\n" +
- " <Country>CA</Country>\n" +
- " <Currency>CAD</Currency>\n" +
- " <DispatchTimeMax>3</DispatchTimeMax>\n" +
- " <ListingDuration>GTC</ListingDuration>\n" +
- " <ListingType>FixedPriceItem</ListingType>\n" +
- " <PaymentMethods>PayPal</PaymentMethods>\n" +
- " <PayPalEmailAddress>canadiandirectconsumer@gmail.com</PayPalEmailAddress>\n" +
- " <PictureDetails>\n" +
- " <GalleryType>Gallery</GalleryType>\n" +
- " <PhotoDisplay>PicturePack</PhotoDisplay>\n" +
- " <PictureURL>https://mypicserver.com/myphoto.jpg</PictureURL>\n" +
- " </PictureDetails>\n" +
- " <ItemSpecifics></ItemSpecifics>\n" +
- " <Location>Toronto, Ontario</Location>\n" +
- " <ProductListingDetails>\n" +
- " <BrandMPN></BrandMPN>\n" +
- " <IncludeStockPhotoURL>true</IncludeStockPhotoURL>\n" +
- " <IncludeeBayProductDetails>false</IncludeeBayProductDetails>\n" +
- " <UseFirstProduct>true</UseFirstProduct>\n" +
- " <UseStockPhotoURLAsGallery>true</UseStockPhotoURLAsGallery>\n" +
- " <ReturnSearchResultOnDuplicates>true</ReturnSearchResultOnDuplicates>\n" +
- " </ProductListingDetails>\n" +
- " <Quantity>1</Quantity>\n" +
- " <ReturnPolicy>\n" +
- " <ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>\n" +
- " <RefundOption>MoneyBack</RefundOption>\n" +
- " <ReturnsWithinOption>Days_30</ReturnsWithinOption>\n" +
- " <ShippingCostPaidByOption>Seller</ShippingCostPaidByOption>\n" +
- " </ReturnPolicy>\n" +
- " <ShippingDetails>\n" +
- " <ShippingType>Flat</ShippingType>\n" +
- " <ShippingServiceOptions>\n" +
- " <ShippingServicePriority>1</ShippingServicePriority>\n" +
- " <ShippingService>CA_StandardShipping</ShippingService>\n" +
- " <FreeShipping>true</FreeShipping>\n" +
- " <ShippingServiceAdditionalCost currencyID=\"CAD\">0.00</ShippingServiceAdditionalCost>\n" +
- " </ShippingServiceOptions>\n" +
- " </ShippingDetails>\n" +
- " <Site>Canada</Site>\n" +
- " </Item>\n" +
- "</AddFixedPriceItemRequest>";
- Document xmlDoc = Jsoup.parse(input, "", Parser.xmlParser());
- xmlDoc.outputSettings().indentAmount(0).prettyPrint(false);
- Element e = xmlDoc.select("eBayAuthToken").first();
- e.text(EbayAssitivePackage.Configuration.ProductionAuthToken);
- e = xmlDoc.select("Title").first();
- if(titleToPost == null)
- {
- e.text(EbayAssitivePackage.EbayTitleBuilder.titleBuilder(amzn));
- }
- if(titleToPost != null)
- {
- e.text(titleToPost);
- }
- e = xmlDoc.select("Description").first();
- e.text(EbayAssitivePackage.DescriptionBuilder.buildHTML(amzn));
- // category
- e = xmlDoc.select("CategoryID").first();
- boolean categoryCheck = false;
- do
- {
- try {
- e.text(EbayAssitivePackage.EbayApi.getSuggestedCategory(amzn.getAmazonTitle()));
- categoryCheck = true;
- }catch(Exception f) {
- f.printStackTrace();
- }
- }while(categoryCheck == false);
- //pics
- e = xmlDoc.select("PictureDetails").first();
- e.text("");
- boolean isImgfirstPhoto = true;
- int x = 0;
- for(String imgUrl: amzn.getAmazonHighResImgList())
- {
- try {
- System.out.println(imgUrl);
- System.out.println("Amazon Original Title: "+amzn.getAmazonTitle());
- String ebayPictureTitle = EbayAssitivePackage.EbayTitleBuilder.titleBuilder(amzn);
- System.out.println("ebayPictureTitle: "+ebayPictureTitle);
- String ebayPictureUrl = "";
- int retries = 0;
- do
- {
- try {
- ebayPictureUrl = EbayApi.UploadSiteHostedPictures(imgUrl, ebayPictureTitle, isImgfirstPhoto);
- retries = 3;
- }catch(Exception f)
- {
- f.printStackTrace();
- }
- retries++;
- }while(retries < 3);
- if(ebayPictureUrl.contains("ebay"))
- {
- e.appendElement("PictureURL").text(ebayPictureUrl);
- }
- isImgfirstPhoto = false;
- }catch(Exception f) {
- f.printStackTrace();
- }
- x++;
- if(x == 12)
- {
- break;
- }
- }
- e = xmlDoc.select("StartPrice").first();
- double setFixedPrice = amzn.getAmznPrice()*1.13*1.45+0.30;
- if(titleToPost == null)
- {
- if(amzn.getAmznMerchant().contains("Amazon")) {
- setFixedPrice = FixedPriceCalculation.getFixedPriceAmazon(amzn.getAmznPrice());
- }
- if(!amzn.getAmznMerchant().contains("Amazon")) {
- setFixedPrice = FixedPriceCalculation.getFixedPriceMerchant(amzn.getAmznPrice());
- }
- }
- e.text(Double.toString(setFixedPrice));
- e = xmlDoc.select("SKU").first();
- e.text(amzn.getSku());
- e = xmlDoc.select("BrandMPN").first();
- e.appendElement("Brand").text(amzn.getAmazonBrand());
- e.appendElement("MPN").text(amzn.getAmazonMpn());
- //NameValueList
- //ItemSpecifics
- e = xmlDoc.select("ItemSpecifics").first();
- Map<String,String> amazonNameValueMap = amzn.getAmazonNameValueMap();
- Map<String, String> reversedMap = new TreeMap<String, String>(amazonNameValueMap);
- for(int i = 0;i<reversedMap.size();i++) {
- e.appendElement("NameValueList");
- }
- int i = 0;
- for (Map.Entry entry : reversedMap.entrySet()) {
- Element nameValueList = e.child(i);
- String name = entry.getKey().toString();
- try {
- name = name.substring(0, 64);
- }catch(Exception f) {
- //f.printStackTrace();
- }
- String value = entry.getValue().toString();
- try {
- value = value.substring(0, 64);
- }catch(Exception f) {
- //f.printStackTrace();
- }
- nameValueList.appendElement("Name").text(name);
- nameValueList.appendElement("Value").text(value);
- i++;
- }
- e.appendElement("NameValueList");
- Element nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Brand");
- nameValueList.appendElement("Value").text(amzn.getAmazonBrand());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("MPN");
- nameValueList.appendElement("Value").text(amzn.getAmazonMpn());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Model");
- nameValueList.appendElement("Value").text(amzn.getAmazonMpn());
- ///ProductListingDetails UPC
- e = xmlDoc.select("ProductListingDetails").first();
- e.appendElement("UPC").text(amzn.getAmazonUpc());
- System.out.println("\n\n\n\n------------------------------------------------------------------------------\n\n\n\n\n");
- System.out.println(xmlDoc);
- System.out.println("------------------------------------------------------------------------------\n\n");
- //--------------------------- Post XML -----------------------------
- Response ebayRes =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDoc.toString())
- .method(Method.POST)
- .execute()
- ;
- Document ebayDoc = ebayRes.parse();
- ebayDoc.outputSettings().indentAmount(3).prettyPrint(true);
- ebayLink = "https://www.ebay.ca/itm/"+ebayDoc.select("ItemId").text();
- System.out.println(ebayDoc);
- //System.out.println("\n\nSucessfully Listed: "+ebayLink+"\n");
- posted = true;
- //------------------------------------if(search==true) {-------------------------------***[Finish]
- ackMessage = ebayDoc.select("Ack").text();
- Document ebayDocRetry = null;
- Document xmlDocumentToRetry = null;
- if(ackMessage.toLowerCase().equals("failure"))
- {
- xmlDocumentToRetry = RelistXmlFunction.retryXml(ebayDoc.toString(), xmlDoc.toString());
- Response ResponseToRetry =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDocumentToRetry.toString())
- .method(Method.POST)
- .execute()
- ;
- ebayDocRetry = ResponseToRetry.parse();
- ackMessage = ebayDocRetry.select("Ack").text();
- ebayLink = "https://www.ebay.ca/itm/"+ebayDocRetry.select("ItemId").text();
- System.out.println(ebayDocRetry);
- }
- if(ackMessage.toLowerCase().equals("failure"))
- {
- Document xmlDocumentToRetry2 = RelistXmlFunction.retryXml(ebayDocRetry.toString(), xmlDocumentToRetry.toString());
- Response ResponseToRetry2 =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDocumentToRetry2.toString())
- .method(Method.POST)
- .execute()
- ;
- Document ebayDocRetry2 = ResponseToRetry2.parse();
- ackMessage = ebayDocRetry2.select("Ack").text();
- ebayLink = "https://www.ebay.ca/itm/"+ebayDocRetry2.select("ItemId").text();
- System.out.println(ebayDocRetry2);
- }
- }
- return ebayLink;
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Finish]
- }
- public String listEbayItem(String ebayUrl) throws IOException, JSONException, InterruptedException {
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Start]
- boolean posted = false;
- String ebayLink = null;
- EbayScrapeFunction ebay = new EbayScrapeFunction(ebayUrl);
- boolean searchEbay = ebay.itemScrapeFunction();
- if(searchEbay==true) {
- //------------------------------------if(search==true) {-------------------------------***[Start]
- String input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
- "<AddFixedPriceItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n" +
- " <RequesterCredentials>\n" +
- " <eBayAuthToken>YOURTOKENHERE</eBayAuthToken>\n" +
- " </RequesterCredentials>\n" +
- " <ErrorLanguage>en_CA</ErrorLanguage>\n" +
- " <WarningLevel>High</WarningLevel>\n" +
- " <Item>\n" +
- " <AutoPay>true</AutoPay>" +
- " <UseTaxTable>true</UseTaxTable>\n" +
- " <Title>Apple MacBook Pro MB990LL/A 13.3 in. Notebook NEW</Title>\n" +
- " <Description>Brand New Apple MacBook Pro MB990LL/A 13.3 in. Notebook!</Description>\n" +
- " <PrimaryCategory>\n" +
- " <CategoryID>111422</CategoryID>\n" +
- " </PrimaryCategory>\n" +
- " <SKU></SKU>\n"+
- " <StartPrice>500.0</StartPrice>\n" +
- " <CategoryMappingAllowed>true</CategoryMappingAllowed>\n" +
- " <ConditionID>1000</ConditionID>\n" +
- " <Country>CA</Country>\n" +
- " <Currency>CAD</Currency>\n" +
- " <DispatchTimeMax>3</DispatchTimeMax>\n" +
- " <ListingDuration>Days_30</ListingDuration>\n" +
- " <ListingType>FixedPriceItem</ListingType>\n" +
- " <PaymentMethods>PayPal</PaymentMethods>\n" +
- " <PayPalEmailAddress>canadiandirectconsumer@gmail.com</PayPalEmailAddress>\n" +
- " <PictureDetails>\n" +
- " <PictureURL>https://mypicserver.com/myphoto.jpg</PictureURL>\n" +
- " </PictureDetails>\n" +
- " <ItemSpecifics></ItemSpecifics>\n" +
- " <Location>Toronto, Ontario</Location>\n" +
- " <ProductListingDetails>\n" +
- " <BrandMPN></BrandMPN>\n" +
- " <IncludeStockPhotoURL>true</IncludeStockPhotoURL>\n" +
- " <IncludeeBayProductDetails>false</IncludeeBayProductDetails>\n" +
- " <UseFirstProduct>true</UseFirstProduct>\n" +
- " <UseStockPhotoURLAsGallery>true</UseStockPhotoURLAsGallery>\n" +
- " <ReturnSearchResultOnDuplicates>true</ReturnSearchResultOnDuplicates>\n" +
- " </ProductListingDetails>\n" +
- " <Quantity>1</Quantity>\n" +
- " <ReturnPolicy>\n" +
- " <ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>\n" +
- " <RefundOption>MoneyBack</RefundOption>\n" +
- " <ReturnsWithinOption>Days_30</ReturnsWithinOption>\n" +
- " <ShippingCostPaidByOption>Seller</ShippingCostPaidByOption>\n" +
- " </ReturnPolicy>\n" +
- " <ShippingDetails>\n" +
- " <ShippingType>Flat</ShippingType>\n" +
- " <ShippingServiceOptions>\n" +
- " <ShippingServicePriority>1</ShippingServicePriority>\n" +
- " <ShippingService>CA_StandardShipping</ShippingService>\n" +
- " <FreeShipping>true</FreeShipping>\n" +
- " <ShippingServiceAdditionalCost currencyID=\"CAD\">0.00</ShippingServiceAdditionalCost>\n" +
- " </ShippingServiceOptions>\n" +
- " </ShippingDetails>\n" +
- " <Site>Canada</Site>\n" +
- " </Item>\n" +
- "</AddFixedPriceItemRequest>";
- Document xmlDoc = Jsoup.parse(input, "", Parser.xmlParser());
- xmlDoc.outputSettings().indentAmount(0).prettyPrint(false);
- Element e = xmlDoc.select("eBayAuthToken").first();
- e.text(EbayAssitivePackage.Configuration.ProductionAuthToken);
- e = xmlDoc.select("Title").first();
- e.text(ebay.getEbayOriginalTitle());
- e = xmlDoc.select("Description").first();
- e.text(ebay.getEbayDescription());
- //category
- e = xmlDoc.select("CategoryID").first();
- if(ebay.getCategoryId() == null || ebay.getCategoryId().isEmpty() || ebay.getCategoryId().contains("9999"))
- {
- boolean categoryCheck = false;
- do
- {
- try
- {
- e.text(EbayAssitivePackage.EbayApi.getSuggestedCategory(ebay.getEbayOriginalTitle()));
- categoryCheck = true;
- }catch(Exception f) {
- f.printStackTrace();
- }
- }while(categoryCheck == false);
- }else
- {
- e.text(ebay.getCategoryId());
- }
- e = xmlDoc.select("PictureDetails").first();
- e.text("");
- int x = 0;
- for(String imgUrl: ebay.getEbayImgList())
- {
- e.appendElement("PictureURL").text(imgUrl);
- x++;
- if(x == 12)
- {
- break;
- }
- }
- double setFixedPrice = ebay.getEbayPrice() - 0.07;;
- setFixedPrice = (double) Math.round(setFixedPrice * 100) / 100;
- e = xmlDoc.select("StartPrice").first();
- e.text(Double.toString(setFixedPrice));
- e = xmlDoc.select("BrandMPN").first();
- e.appendElement("Brand").text(ebay.getEbayBrand());
- e.appendElement("MPN").text(ebay.getEbayMpn());
- //NameValueList
- //ItemSpecifics
- e = xmlDoc.select("ItemSpecifics").first();
- Map<String,String> ebayNameValueMap = ebay.getEbayNameValueMap();
- Map<String, String> reversedMap = new TreeMap<String, String>(ebayNameValueMap);
- for(int i = 0;i<reversedMap.size();i++) {
- e.appendElement("NameValueList");
- }
- int i = 0;
- for (Map.Entry entry : reversedMap.entrySet()) {
- Element nameValueList = e.child(i);
- String name = entry.getKey().toString();
- try {
- name = name.substring(0, 64);
- }catch(Exception f) {
- f.printStackTrace();
- }
- String value = entry.getValue().toString();
- try {
- value = value.substring(0, 64);
- }catch(Exception f) {
- //f.printStackTrace();
- }
- nameValueList.appendElement("Name").text(name);
- nameValueList.appendElement("Value").text(value);
- i++;
- }
- e.appendElement("NameValueList");
- Element nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Brand");
- nameValueList.appendElement("Value").text(ebay.getEbayBrand());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("MPN");
- nameValueList.appendElement("Value").text(ebay.getEbayMpn());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Model");
- nameValueList.appendElement("Value").text(ebay.getEbayMpn());
- //ProductListingDetails UPC
- e = xmlDoc.select("ProductListingDetails").first();
- e.appendElement("UPC").text(ebay.getEbayUpc());
- System.out.println("------------------------------------------------------------------------------\n\n");
- System.out.println(xmlDoc);
- System.out.println("------------------------------------------------------------------------------\n\n");
- //--------------------------- Post XML -----------------------------
- Response ebayRes =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDoc.toString())
- .method(Method.POST)
- .execute()
- ;
- Document ebayDoc = ebayRes.parse();
- ebayDoc.outputSettings().indentAmount(3).prettyPrint(true);
- ebayLink = "https://www.ebay.ca/itm/"+ebayDoc.select("ItemId").text();
- System.out.println(ebayDoc);
- System.out.println("\n\nSucessfully Listed: "+ebayLink+"\n");
- posted = true;
- //------------------------------------if(search==true) {-------------------------------***[Finish]
- }
- return ebayLink;
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Finish]
- }
- public String listEbayWithTrackingItem(String ebayUrl, String amazonUrl) throws IOException, JSONException, InterruptedException, AWTException {
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Start]
- boolean posted = false;
- String ebayLink = null;
- EbayScrapeFunction ebay = new EbayScrapeFunction(ebayUrl);
- boolean searchEbay = ebay.itemScrapeFunction();
- AmznTrackingFunction amzn = new AmznTrackingFunction(amazonUrl);
- boolean search = amzn.search();
- amznAsin = amzn.getAmznAsin();
- if(amzn.isListingVero() == true)
- {
- System.out.println("--------------------ERROR----------------------------[START}\n" +
- "\n" +
- "\n" +
- "ITEM IS VERO PROTECTED: \n" +
- "\n" +
- "\n" +
- "\n" +
- "PLEASE ENTER VALID & UNPOSTED ITEM\n" +
- "\n" +
- "\n" +
- "\n" +
- "--------------------ERROR----------------------------[END]");
- }
- if(amzn.isItemOutOfStock() == true)
- {
- System.out.println("--------------------ERROR----------------------------[START}\n" +
- "\n" +
- "\n" +
- "ITEM IS OUT OF STOCK: \n" +
- "\n" +
- "\n" +
- "\n" +
- "PLEASE ENTER VALID & UNPOSTED ITEM\n" +
- "\n" +
- "\n" +
- "\n" +
- "--------------------ERROR----------------------------[END]");
- }
- if(search==true && searchEbay==true && amzn.isListingVero() == false && amzn.isItemOutOfStock() == false) {
- //------------------------------------if(search==true) {-------------------------------***[Start]
- String input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
- "<AddFixedPriceItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n" +
- " <RequesterCredentials>\n" +
- " <eBayAuthToken>YOURTOKENHERE</eBayAuthToken>\n" +
- " </RequesterCredentials>\n" +
- " <ErrorLanguage>en_CA</ErrorLanguage>\n" +
- " <WarningLevel>High</WarningLevel>\n" +
- " <Item>\n" +
- " <AutoPay>true</AutoPay>" +
- " <UseTaxTable>true</UseTaxTable>\n" +
- " <Title>Apple MacBook Pro MB990LL/A 13.3 in. Notebook NEW</Title>\n" +
- " <Description>Brand New Apple MacBook Pro MB990LL/A 13.3 in. Notebook!</Description>\n" +
- " <PrimaryCategory>\n" +
- " <CategoryID>111422</CategoryID>\n" +
- " </PrimaryCategory>\n" +
- " <SKU> SKUType (string) </SKU>\n"+
- " <StartPrice>500.0</StartPrice>\n" +
- " <CategoryMappingAllowed>true</CategoryMappingAllowed>\n" +
- " <ConditionID>1000</ConditionID>\n" +
- " <Country>CA</Country>\n" +
- " <Currency>CAD</Currency>\n" +
- " <DispatchTimeMax>3</DispatchTimeMax>\n" +
- " <ListingDuration>GTC</ListingDuration>\n" +
- " <ListingType>FixedPriceItem</ListingType>\n" +
- " <PaymentMethods>PayPal</PaymentMethods>\n" +
- " <PayPalEmailAddress>canadiandirectconsumer@gmail.com</PayPalEmailAddress>\n" +
- " <PictureDetails>\n" +
- " <PictureURL>https://mypicserver.com/myphoto.jpg</PictureURL>\n" +
- " </PictureDetails>\n" +
- " <ItemSpecifics></ItemSpecifics>\n" +
- " <Location>Toronto, Ontario</Location>\n" +
- " <ProductListingDetails>\n" +
- " <BrandMPN></BrandMPN>\n" +
- " <IncludeStockPhotoURL>true</IncludeStockPhotoURL>\n" +
- " <IncludeeBayProductDetails>true</IncludeeBayProductDetails>\n" +
- " <UseFirstProduct>true</UseFirstProduct>\n" +
- " <UseStockPhotoURLAsGallery>true</UseStockPhotoURLAsGallery>\n" +
- " <ReturnSearchResultOnDuplicates>true</ReturnSearchResultOnDuplicates>\n" +
- " </ProductListingDetails>\n" +
- " <Quantity>1</Quantity>\n" +
- " <ReturnPolicy>\n" +
- " <ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>\n" +
- " <RefundOption>MoneyBack</RefundOption>\n" +
- " <ReturnsWithinOption>Days_14</ReturnsWithinOption>\n" +
- " <ShippingCostPaidByOption>Seller</ShippingCostPaidByOption>\n" +
- " </ReturnPolicy>\n" +
- " <ShippingDetails>\n" +
- " <ShippingType>Flat</ShippingType>\n" +
- " <ShippingServiceOptions>\n" +
- " <ShippingServicePriority>1</ShippingServicePriority>\n" +
- " <ShippingService>CA_StandardShipping</ShippingService>\n" +
- " <FreeShipping>true</FreeShipping>\n" +
- " <ShippingServiceAdditionalCost currencyID=\"CAD\">0.00</ShippingServiceAdditionalCost>\n" +
- " </ShippingServiceOptions>\n" +
- " </ShippingDetails>\n" +
- " <Site>Canada</Site>\n" +
- " </Item>\n" +
- "</AddFixedPriceItemRequest>";
- Document xmlDoc = Jsoup.parse(input, "", Parser.xmlParser());
- xmlDoc.outputSettings().indentAmount(0).prettyPrint(false);
- Element e = xmlDoc.select("eBayAuthToken").first();
- e.text(EbayAssitivePackage.Configuration.ProductionAuthToken);
- e = xmlDoc.select("Title").first();
- e.text(ebay.getEbayOriginalTitle());
- e = xmlDoc.select("Description").first();
- e.text(EbayAssitivePackage.DescriptionBuilder.buildHTML(amzn));
- e = xmlDoc.select("CategoryID").first();
- if(ebay.getCategoryId() == null || ebay.getCategoryId().isEmpty() || ebay.getCategoryId().contains("9999"))
- {
- boolean categoryCheck = false;
- do
- {
- try {
- e.text(EbayAssitivePackage.EbayApi.getSuggestedCategory(ebay.getEbayOriginalTitle()));
- categoryCheck = true;
- }catch(Exception f) {
- f.printStackTrace();
- }
- }while(categoryCheck == false);
- }else {
- e.text(ebay.getCategoryId());
- }
- e = xmlDoc.select("PictureDetails").first();
- e.text("");
- int x = 0;
- for(String imgUrl: ebay.getEbayImgList())
- {
- e.appendElement("PictureURL").text(imgUrl);
- x++;
- if(x == 12)
- {
- break;
- }
- }
- double setFixedPrice = ebay.getEbayPrice() - 0.07;;
- setFixedPrice = (double) Math.round(setFixedPrice * 100) / 100;
- e = xmlDoc.select("StartPrice").first();
- e.text(Double.toString(setFixedPrice));
- e = xmlDoc.select("SKU").first();
- e.text(amzn.getSku());
- e = xmlDoc.select("BrandMPN").first();
- e.appendElement("Brand").text(amzn.getAmazonBrand());
- e.appendElement("MPN").text(amzn.getAmazonMpn());
- //NameValueList
- //ItemSpecifics
- e = xmlDoc.select("ItemSpecifics").first();
- Map<String,String> amazonNameValueMap = amzn.getAmazonNameValueMap();
- Map<String, String> reversedMap = new TreeMap<String, String>(amazonNameValueMap);
- for(int i = 0;i<reversedMap.size();i++) {
- e.appendElement("NameValueList");
- }
- int i = 0;
- for (Map.Entry entry : reversedMap.entrySet()) {
- Element nameValueList = e.child(i);
- String name = entry.getKey().toString();
- try {
- name = name.substring(0, 64);
- }catch(Exception f) {
- f.printStackTrace();
- }
- String value = entry.getValue().toString();
- try {
- value = value.substring(0, 64);
- }catch(Exception f) {
- //f.printStackTrace();
- }
- nameValueList.appendElement("Name").text(name);
- nameValueList.appendElement("Value").text(value);
- i++;
- }
- e.appendElement("NameValueList");
- Element nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Brand");
- nameValueList.appendElement("Value").text(amzn.getAmazonBrand());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("MPN");
- nameValueList.appendElement("Value").text(amzn.getAmazonMpn());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Model");
- nameValueList.appendElement("Value").text(amzn.getAmazonMpn());
- //StartPrice
- //ProductListingDetails
- e = xmlDoc.select("ProductListingDetails").first();
- e.appendElement("UPC").text(ebay.getEbayUpc());
- //System.out.println("------------------------------------------------------------------------------\n\n");
- //System.out.println(xmlDoc);
- //System.out.println("------------------------------------------------------------------------------\n\n");
- //--------------------------- Post XML -----------------------------
- Response ebayRes =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDoc.toString())
- .method(Method.POST)
- .execute()
- ;
- Document ebayDoc = ebayRes.parse();
- ebayDoc.outputSettings().indentAmount(3).prettyPrint(true);
- ebayLink = "https://www.ebay.ca/itm/"+ebayDoc.select("ItemId").text();
- //System.out.println(ebayDoc);
- //System.out.println("\n\nSucessfully Listed: "+ebayLink+"\n");
- ackMessage = ebayDoc.select("Ack").text();
- Document ebayDocRetry = null;
- Document xmlDocumentToRetry = null;
- if(ackMessage.toLowerCase().equals("failure"))
- {
- xmlDocumentToRetry = RelistXmlFunction.retryXml(ebayDoc.toString(), xmlDoc.toString());
- Response ResponseToRetry =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDocumentToRetry.toString())
- .method(Method.POST)
- .execute()
- ;
- ebayDocRetry = ResponseToRetry.parse();
- ackMessage = ebayDocRetry.select("Ack").text();
- ebayLink = "https://www.ebay.ca/itm/"+ebayDocRetry.select("ItemId").text();
- System.out.println(ebayDocRetry);
- }
- if(ackMessage.toLowerCase().equals("failure"))
- {
- Document xmlDocumentToRetry2 = RelistXmlFunction.retryXml(ebayDocRetry.toString(), xmlDocumentToRetry.toString());
- Response ResponseToRetry2 =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDocumentToRetry2.toString())
- .method(Method.POST)
- .execute()
- ;
- Document ebayDocRetry2 = ResponseToRetry2.parse();
- ackMessage = ebayDocRetry2.select("Ack").text();
- ebayLink = "https://www.ebay.ca/itm/"+ebayDocRetry2.select("ItemId").text();
- System.out.println(ebayDocRetry2);
- }
- posted = true;
- //------------------------------------if(search==true) {-------------------------------***[Finish]
- }
- return ebayLink;
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Finish]
- }
- public String listEbayWithTrackingItemOriginalImages(String ebayUrl, String amazonUrl) throws IOException, JSONException, InterruptedException, AWTException {
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Start]
- boolean posted = false;
- String ebayLink = null;
- EbayScrapeFunction ebay = new EbayScrapeFunction(ebayUrl);
- boolean searchEbay = ebay.itemScrapeFunction();
- AmznTrackingFunction amzn = new AmznTrackingFunction(amazonUrl);
- boolean search = amzn.search();
- amznAsin = amzn.getAmznAsin();
- if(amzn.isListingVero() == true)
- {
- System.out.println("--------------------ERROR----------------------------[START}\n" +
- "\n" +
- "\n" +
- "ITEM IS VERO PROTECTED: \n" +
- "\n" +
- "\n" +
- "\n" +
- "PLEASE ENTER VALID & UNPOSTED ITEM\n" +
- "\n" +
- "\n" +
- "\n" +
- "--------------------ERROR----------------------------[END]");
- }
- if(amzn.isItemOutOfStock() == true)
- {
- System.out.println("--------------------ERROR----------------------------[START}\n" +
- "\n" +
- "\n" +
- "ITEM IS OUT OF STOCK: \n" +
- "\n" +
- "\n" +
- "\n" +
- "PLEASE ENTER VALID & UNPOSTED ITEM\n" +
- "\n" +
- "\n" +
- "\n" +
- "--------------------ERROR----------------------------[END]");
- }
- if(search==true && searchEbay==true && amzn.isListingVero() == false && amzn.isItemOutOfStock() == false) {
- //------------------------------------if(search==true) {-------------------------------***[Start]
- String input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
- "<AddFixedPriceItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n" +
- " <RequesterCredentials>\n" +
- " <eBayAuthToken>YOURTOKENHERE</eBayAuthToken>\n" +
- " </RequesterCredentials>\n" +
- " <ErrorLanguage>en_CA</ErrorLanguage>\n" +
- " <WarningLevel>High</WarningLevel>\n" +
- " <Item>\n" +
- " <AutoPay>true</AutoPay>" +
- " <UseTaxTable>true</UseTaxTable>\n" +
- " <Title>Apple MacBook Pro MB990LL/A 13.3 in. Notebook NEW</Title>\n" +
- " <Description>Brand New Apple MacBook Pro MB990LL/A 13.3 in. Notebook!</Description>\n" +
- " <PrimaryCategory>\n" +
- " <CategoryID>111422</CategoryID>\n" +
- " </PrimaryCategory>\n" +
- " <SKU> SKUType (string) </SKU>\n"+
- " <StartPrice>500.0</StartPrice>\n" +
- " <CategoryMappingAllowed>true</CategoryMappingAllowed>\n" +
- " <ConditionID>1000</ConditionID>\n" +
- " <Country>CA</Country>\n" +
- " <Currency>CAD</Currency>\n" +
- " <DispatchTimeMax>3</DispatchTimeMax>\n" +
- " <ListingDuration>GTC</ListingDuration>\n" +
- " <ListingType>FixedPriceItem</ListingType>\n" +
- " <PaymentMethods>PayPal</PaymentMethods>\n" +
- " <PayPalEmailAddress>canadiandirectconsumer@gmail.com</PayPalEmailAddress>\n" +
- " <PictureDetails>\n" +
- " <PictureURL>https://mypicserver.com/myphoto.jpg</PictureURL>\n" +
- " </PictureDetails>\n" +
- " <ItemSpecifics></ItemSpecifics>\n" +
- " <Location>Toronto, Ontario</Location>\n" +
- " <ProductListingDetails>\n" +
- " <BrandMPN></BrandMPN>\n" +
- " <IncludeStockPhotoURL>true</IncludeStockPhotoURL>\n" +
- " <IncludeeBayProductDetails>true</IncludeeBayProductDetails>\n" +
- " <UseFirstProduct>true</UseFirstProduct>\n" +
- " <UseStockPhotoURLAsGallery>true</UseStockPhotoURLAsGallery>\n" +
- " <ReturnSearchResultOnDuplicates>true</ReturnSearchResultOnDuplicates>\n" +
- " </ProductListingDetails>\n" +
- " <Quantity>1</Quantity>\n" +
- " <ReturnPolicy>\n" +
- " <ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>\n" +
- " <RefundOption>MoneyBack</RefundOption>\n" +
- " <ReturnsWithinOption>Days_14</ReturnsWithinOption>\n" +
- " <ShippingCostPaidByOption>Seller</ShippingCostPaidByOption>\n" +
- " </ReturnPolicy>\n" +
- " <ShippingDetails>\n" +
- " <ShippingType>Flat</ShippingType>\n" +
- " <ShippingServiceOptions>\n" +
- " <ShippingServicePriority>1</ShippingServicePriority>\n" +
- " <ShippingService>CA_StandardShipping</ShippingService>\n" +
- " <FreeShipping>true</FreeShipping>\n" +
- " <ShippingServiceAdditionalCost currencyID=\"CAD\">0.00</ShippingServiceAdditionalCost>\n" +
- " </ShippingServiceOptions>\n" +
- " </ShippingDetails>\n" +
- " <Site>Canada</Site>\n" +
- " </Item>\n" +
- "</AddFixedPriceItemRequest>";
- Document xmlDoc = Jsoup.parse(input, "", Parser.xmlParser());
- xmlDoc.outputSettings().indentAmount(0).prettyPrint(false);
- Element e = xmlDoc.select("eBayAuthToken").first();
- e.text(EbayAssitivePackage.Configuration.ProductionAuthToken);
- e = xmlDoc.select("Title").first();
- e.text(ebay.getEbayOriginalTitle());
- e = xmlDoc.select("Description").first();
- e.text(EbayAssitivePackage.DescriptionBuilder.buildHTML(amzn));
- e = xmlDoc.select("CategoryID").first();
- if(ebay.getCategoryId() == null || ebay.getCategoryId().isEmpty() || ebay.getCategoryId().contains("9999"))
- {
- boolean categoryCheck = false;
- do
- {
- try {
- e.text(EbayAssitivePackage.EbayApi.getSuggestedCategory(ebay.getEbayOriginalTitle()));
- categoryCheck = true;
- }catch(Exception f) {
- f.printStackTrace();
- }
- }while(categoryCheck == false);
- }else {
- e.text(ebay.getCategoryId());
- }
- //pics
- e = xmlDoc.select("PictureDetails").first();
- e.text("");
- boolean isImgfirstPhoto = true;
- int x = 0;
- for(String imgUrl: amzn.getAmazonHighResImgList())
- {
- try {
- System.out.println(imgUrl);
- System.out.println("Amazon Original Title: "+amzn.getAmazonTitle());
- String ebayPictureTitle = EbayAssitivePackage.EbayTitleBuilder.titleBuilder(amzn);
- System.out.println("ebayPictureTitle: "+ebayPictureTitle);
- String ebayPictureUrl = "";
- int retries = 0;
- do
- {
- try {
- ebayPictureUrl = EbayApi.UploadSiteHostedPictures(imgUrl, ebayPictureTitle, isImgfirstPhoto);
- retries = 3;
- }catch(Exception f)
- {
- f.printStackTrace();
- }
- retries++;
- }while(retries < 3);
- if(ebayPictureUrl.contains("ebay"))
- {
- e.appendElement("PictureURL").text(ebayPictureUrl);
- x++;
- }
- isImgfirstPhoto = false;
- }catch(Exception f) {
- f.printStackTrace();
- }
- if(x==12)
- {
- break;
- }
- }
- //Price
- double setFixedPrice = ebay.getEbayPrice() - 0.07;;
- setFixedPrice = (double) Math.round(setFixedPrice * 100) / 100;
- e = xmlDoc.select("StartPrice").first();
- e.text(Double.toString(setFixedPrice));
- e = xmlDoc.select("SKU").first();
- e.text(amzn.getSku());
- e = xmlDoc.select("BrandMPN").first();
- e.appendElement("Brand").text(amzn.getAmazonBrand());
- e.appendElement("MPN").text(amzn.getAmazonMpn());
- //NameValueList
- //ItemSpecifics
- e = xmlDoc.select("ItemSpecifics").first();
- Map<String,String> amazonNameValueMap = amzn.getAmazonNameValueMap();
- Map<String, String> reversedMap = new TreeMap<String, String>(amazonNameValueMap);
- for(int i = 0;i<reversedMap.size();i++) {
- e.appendElement("NameValueList");
- }
- int i = 0;
- for (Map.Entry entry : reversedMap.entrySet()) {
- Element nameValueList = e.child(i);
- String name = entry.getKey().toString();
- try {
- name = name.substring(0, 64);
- }catch(Exception f) {
- f.printStackTrace();
- }
- String value = entry.getValue().toString();
- try {
- value = value.substring(0, 64);
- }catch(Exception f) {
- //f.printStackTrace();
- }
- nameValueList.appendElement("Name").text(name);
- nameValueList.appendElement("Value").text(value);
- i++;
- }
- e.appendElement("NameValueList");
- Element nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Brand");
- nameValueList.appendElement("Value").text(amzn.getAmazonBrand());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("MPN");
- nameValueList.appendElement("Value").text(amzn.getAmazonMpn());
- i++;
- e.appendElement("NameValueList");
- nameValueList = e.child(i);
- nameValueList.appendElement("Name").text("Model");
- nameValueList.appendElement("Value").text(amzn.getAmazonMpn());
- //StartPrice
- //ProductListingDetails
- e = xmlDoc.select("ProductListingDetails").first();
- e.appendElement("UPC").text(ebay.getEbayUpc());
- //System.out.println("------------------------------------------------------------------------------\n\n");
- //System.out.println(xmlDoc);
- //System.out.println("------------------------------------------------------------------------------\n\n");
- //--------------------------- Post XML -----------------------------
- Response ebayRes =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDoc.toString())
- .method(Method.POST)
- .execute()
- ;
- Document ebayDoc = ebayRes.parse();
- ebayDoc.outputSettings().indentAmount(3).prettyPrint(true);
- ebayLink = "https://www.ebay.ca/itm/"+ebayDoc.select("ItemId").text();
- //System.out.println(ebayDoc);
- //System.out.println("\n\nSucessfully Listed: "+ebayLink+"\n");
- ackMessage = ebayDoc.select("Ack").text();
- Document ebayDocRetry = null;
- Document xmlDocumentToRetry = null;
- if(ackMessage.toLowerCase().equals("failure"))
- {
- xmlDocumentToRetry = RelistXmlFunction.retryXml(ebayDoc.toString(), xmlDoc.toString());
- Response ResponseToRetry =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDocumentToRetry.toString())
- .method(Method.POST)
- .execute()
- ;
- ebayDocRetry = ResponseToRetry.parse();
- ackMessage = ebayDocRetry.select("Ack").text();
- ebayLink = "https://www.ebay.ca/itm/"+ebayDocRetry.select("ItemId").text();
- System.out.println(ebayDocRetry);
- }
- if(ackMessage.toLowerCase().equals("failure"))
- {
- Document xmlDocumentToRetry2 = RelistXmlFunction.retryXml(ebayDocRetry.toString(), xmlDocumentToRetry.toString());
- Response ResponseToRetry2 =
- Jsoup.connect("https://api.ebay.com/ws/api.dll") //https://api.ebay.com/ws/api.dll
- .ignoreContentType(true)
- .ignoreHttpErrors(true)
- .header("Content-type", "text/xml")
- .header("X-EBAY-API-COMPATIBILITY-LEVEL", "911")
- .header("X-EBAY-API-SITEID", "2")
- .header("X-EBAY-API-CALL-NAME", "AddFixedPriceItem")
- .header("X-EBAY-API-APP-NAME", "TehseenA-hockeygr-PRD-8ea920fd0-0ada6f57")
- .header("X-EBAY-API-CERT-NAME", "PRD-ea920fd07393-3735-4b13-8fe1-ade8")
- .header("X-EBAY-API-DEV-NAME", "d58b693b-cfd5-4515-9b7d-e1432bbfb7d7")
- .requestBody(xmlDocumentToRetry2.toString())
- .method(Method.POST)
- .execute()
- ;
- Document ebayDocRetry2 = ResponseToRetry2.parse();
- ackMessage = ebayDocRetry2.select("Ack").text();
- ebayLink = "https://www.ebay.ca/itm/"+ebayDocRetry2.select("ItemId").text();
- System.out.println(ebayDocRetry2);
- }
- posted = true;
- //------------------------------------if(search==true) {-------------------------------***[Finish]
- }
- return ebayLink;
- //-public static void main(String[] args) throws IOException, JSONException {-------------------***[Finish]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement