Created
August 8, 2016 14:44
-
-
Save takvol/d6b5ce17580b84b314e10f9f5fa4ab08 to your computer and use it in GitHub Desktop.
Custom function in GAS that takes eBay item URL and returns item category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCategory(itemUrl) { | |
var itemID = itemUrl.slice(itemUrl.lastIndexOf('/') + 1); | |
Logger.log(itemID); | |
var parameters = | |
"?callname=GetSingleItem" + | |
"&responseencoding=JSON" + | |
"&appid=" + "YourAppIDHere" + | |
"&siteid=0" + | |
"&version=963" + | |
"&ItemID=" + itemID; | |
var result = JSON.parse(UrlFetchApp.fetch("http://open.api.ebay.com/shopping" + parameters).getContentText()); | |
var category = result.Item.PrimaryCategoryID; | |
return category; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment