davidtsadler / ebay-sdk-php

An eBay SDK for PHP. Use the eBay API in your PHP projects.
Apache License 2.0
350 stars 343 forks source link

Get relist item ID after product expired in the Shopping Service #203

Closed mx-rz closed 6 years ago

mx-rz commented 6 years ago

Hi everyone I build service to review anything products. The writer creates an article and fills products to it. We use DTS\eBaySDK\Shopping\Services\ShoppingService with method getMultipleItems() by getting information about the product, but we have a problem with products which expired and has been relisted

For example: If writer added a link to the product on the eBay: https://www.ebay.de/itm/Lego-Darth-Vader-TIE-Fighter-8017-Anleitung-OVP-/123190324900 And after its expired time of the product and if you go to this link you will have a redirect to https://www.ebay.de/itm/Display-stand-angled-no-3-for-75105-7965-Millennium-Falcon-Star-Wars-Lego-/172850356481?oid=123190324900 , this a product with new ItemID, which can contain different cost, name, and other information.

Could you explain how we can get a new ItemID on which redirect on basic request from the browser?

I try to use method getItem in the DTS\eBaySDK\Trading\Services\TradingService for get Item.ListingDetails.RelistedItemID, but I have got error:

$service = service = new TradingService([
    'credentials' => $this->availableAccs[$this->currentAccKey],
    'siteId'      => $this->siteId // DTS\eBaySDK\Constants\SiteIds::DE
]); 
$request = new GetItemRequestType();
$request->DetailLevel[] = DetailLevelCodeType::C_RETURN_ALL;
$request->ItemID = $itemsIdString;
$response = $service->getItem($request);

Response:

`GetItemResponseType {#507 ▼
  -values: array:5 [▼
    "Timestamp" => DateTime @1529747514 {#506 ▶}
    "Ack" => "Failure"
    "Errors" => RepeatableType {#526 ▼
      -data: array:1 [▼
        0 => ErrorType {#518 ▼
          -values: array:5 [▼
            "ShortMessage" => "No Password and no token."
            "LongMessage" => "No XML <RequestPassword> or <RequestToken> was found in XML Request."
            "ErrorCode" => "930"
            "SeverityCode" => "Error"
            "ErrorClassification" => "RequestError"
          ]
          -attachment: array:2 [▼
            "data" => null
            "mimeType" => null
          ]
        }
      ]
      -position: 0
      -class: "DTS\eBaySDK\Trading\Types\GetItemResponseType"
      -property: "Errors"
      -expectedType: "DTS\eBaySDK\Trading\Types\ErrorType"
    }
    "Version" => "1063"
    "Build" => "E1063_CORE_API_18716213_R1"
  ]
  -attachment: array:2 [▼
    "data" => null
    "mimeType" => null
  ]
}
michabbb commented 6 years ago

please read the wiki or inspect the samples.

Dmitri10 commented 6 years ago

Hi guys. I'd like to have the same feature(to extract a new Item ID if I have an ended one ) But I'm not an owner of relisted item. So it seems I can't use TradingService to get this kind of info. I've searched in official docs, articles, questions on stakoverflow and others to find another way.

The only thing I see is usage curl with redirect to extract a new ID, but captcha can brake it.

@michabbb Could you suggest something please?

michabbb commented 6 years ago

@Dmitri10 as far as i know: the getitem call gives you the "old itemid" of your own listings. i never had the need before to get this info from foreign listings so i don´t know the perfect solution here. but why don´t u ask the professional ebay support ? if there is another way, the will know - and tell you.

Dmitri10 commented 6 years ago

@michabbb I'll get their response in 24-48 h so I wondered here if you or Topic author had the same problem.

Dmitri10 commented 6 years ago

Guys, just FYI here is just a part of message from eBay support related to my question:

No, you cannot extract a relisted item ID using the old item ID. There is no option on our advanced search to do that. If you wish to get the relisted item ID, you can contact the seller.

Thank you anyway. Have a nice day!

michabbb commented 6 years ago

@Dmitri10 many thanks for letting us know

n588E commented 6 years ago

If I understood your question correctly there is a way to get latest eBay item ID. The answer from eBay is wrong. I needed this functionality myself, and I solved this problem a while back. Here is what I did to find latest relisted item id:

I used Services\TradingService(...) and GetItemRequestType() call. Just pass the item id you have like this:

$request = new Types\GetItemRequestType();
$request->ItemID = $ItemID;
$request->DetailLevel = ['ReturnAll'];
$request->OutputSelector = ['SellingStatus', 'ListingDetails'];
$response = $service->getItem($request);

if (isset($response->Item->ListingDetails->RelistedItemID)){
            $RelistedItemID = $response->Item->ListingDetails->RelistedItemID;
} ... 

Obviously you have to handle the situation when RelistedItemID is not present. I used do .. while loop to control when to stop following the ids. When there is no new RelistedItemID then I check if the listing is still active with: $response->Item->SellingStatus->ListingStatus If listing is active then this is the latest ItemID. Otherwise item was not relisted. It is possible that the seller simply created a new listing using same title and props etc.

You can use this method for your own and other sellers items.

I hope this will put you on the right track. I recommend reading official ebay API docs as I spend hours and hours reading it :) Perhaps there is another way to get the same result. If there is please let me know.

Best Regards A.

michabbb commented 6 years ago

btw.. why don´t people never close their issues... i will never understand this... 🤔