简体   繁体   English

php,CodeIgniter-亚马逊产品广告API,如何从产品URL获取ASIN

[英]php, CodeIgniter- Amazon Product Advertising API, how to get ASIN from a product URL

A text box in the page. 页面中的文本框。 User will paste a product url from Amazon.com and then click a button beside the text box. 用户将粘贴来自Amazon.com的产品URL,然后单击文本框旁边的按钮。 Then weight and dimension of the product needs to be received so that these can be utilized later. 然后需要接收产品的重量和尺寸,以便以后使用。 pressing the button will invoke a jquery ajax call. 按下按钮将调用jquery ajax调用。

From the Amazon Product Advertising write-ups, it seems that ASIN is necessary first to get any detail from the product. 从亚马逊产品广告文章来看,似乎首先需要ASIN才能从产品中获取任何细节。 But how can I get the ASIN from the product URL? 但是如何从产品URL获取ASIN?

A sample product url is: here . 产品网址示例为: 此处

I am using php CodeIgniter 我正在使用php CodeIgniter

In ruby on rails, I used the following method,so far it works well. 在轨道上的红宝石中,我使用了以下方法,到目前为止效果很好。

def parse_url
    url=self.url.match("/([A-Z0-9]{10})").to_s
    len = url.size
    url=url.slice!(1,len)
end

It should be very similar in PHP. 它在PHP中应该非常相似。 Sorry I am not expert with PHP regex syntax. 抱歉,我不是PHP regex语法的专家。 But good luck! 但是,祝你好运! This is base on the ASIN is always 10 char long and start with capital letters, consist with letters and numbers only. 这基于ASIN始终为10个字符长,并以大写字母开头,仅包含字母和数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM