• PHP语言基础知识,电商API代码生成


    前言
    PHP是安全中需要掌握的一门语言,就这么一点儿时间教网络安全,不可能精通,这里就不要求你精通PHP,但是对于一些基础代码能够认识、能够编写那么就可以了。

    同时,这里需要和HTML结合,如果你HTML还没懂,那么就需要加强一些HTML的技术能力了。值得一提的是,你看网页中那么多HTML代码,真的是人去写的么,那是不现实的,都是通过框架自动生成的,像现在的少儿编程不也是一样么。

    PHP语言介绍
    外文名PHP:Hypertext Preprocessor,中文名:“超文本预处理器”是一种通用开源脚本语言。语法吸收了C语言、java和Perl的特点,利于学习,使用广泛,主要适用于web开发领域。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。

    PHP语言,API调用

    item_get-获得淘宝商品详情

    公共参数

    请求地址: https://console.open.onebound.cn/console/?i=Anzexi

    名称类型必须描述
    keyString调用key(必须以GET方式拼接在URL中)
    secretString调用密钥
    api_nameStringAPI接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等]
    cacheString[yes,no]默认yes,将调用缓存的数据,速度比较快
    result_typeString[json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读
    langString[cn,en,ru]翻译语言,默认cn简体中文
    versionStringAPI版本

    请求参数

    请求参数:num_iid=520813250866&is_promotion=1

    参数说明:num_iid:淘宝商品ID
    is_promotion:是否获取取促销价

    请求示例

    1. // 请求示例 url 默认请求参数已经URL编码处理
    2. // 本示例代码未加密secret参数明文传输,若要加密请参考:https://open.onebound.cn/help/demo/sdk/demo-sign.php
    3. $method = "GET";
    4. $url = "https://api-gw.onebound.cn/taobao/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=520813250866&is_promotion=1";
    5. $curl = curl_init();
    6. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
    7. curl_setopt($curl, CURLOPT_URL, $url);
    8. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
    9. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,FALSE);
    10. curl_setopt($curl, CURLOPT_FAILONERROR, false);
    11. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    12. curl_setopt($curl, CURLOPT_HEADER, true);
    13. curl_setopt($curl, CURLOPT_ENCODING, "gzip");
    14. var_dump(curl_exec($curl));
    15. ?>

    响应示例

    1. {
    2. "item": {
    3. "num_iid": "520813250866",
    4. "title": "三刃木折叠刀过安检创意迷你钥匙扣钥匙刀军刀随身多功能小刀包邮",
    5. "desc_short": "",
    6. "price": 25.8,
    7. "total_price": 0,
    8. "suggestive_price": 0,
    9. "orginal_price": "25.80",
    10. "nick": "欢乐购客栈",
    11. "num": "832",
    12. "min_num": 0,
    13. "detail_url": "http://item.taobao.com/item.htm?id=520813250866",
    14. "pic_url": "//img.alicdn.com/imgextra/i4/2596264565/TB2p30elFXXXXXQXpXXXXXXXXXX_!!2596264565.jpg",
    15. "brand": "三刃木",
    16. "brandId": "4036703",
    17. "rootCatId": "50013886",
    18. "cid": "50014822",
    19. "favcount": "4824",
    20. "fanscount": "1469",
    21. "crumbs": [],
    22. "created_time": "",
    23. "modified_time": "",
    24. "delist_time": "",
    25. "desc": "

      \"text-align:center;\">\"color:#ff0000;\">\"font-size:24.0px;\">小店所有产品都支持刻字,如需刻字,拍之前联系客服即可。

      \"text-align:center;\">\"font-size:18.0px;\">炎炎夏日来临,一把随身携带便携式的折叠小刀,\"color:#ff0000;\">带开瓶器功能,喝酒不用愁。(钥匙刀不带开瓶器功能)

      \"text-align:center;\">\"color:#000000;line-height:1.5;\">\"font-size:18.0px;\">\"line-height:18.0px;\">可以当吊牌项链装饰,也可当钥匙扣挂饰, 水果刀 开瓶器 户外防身.

      \"text-align:center;\">\"line-height:1.5;\">\"font-size:24.0px;\">部分客户跟我们反映链子质量还不够好,因此小店已重新订购一批质量更好的链子赠送,\"color:#ff0000;\">加量不加价,只为让你买的更舒心,戴的更放心。

      \"text-align:center;\">\"font-size:36.0px;\">购买就送\"color:#ff0000;\">工具刀卡和链子一条

      \"text-align:center;\">\"font-size:36.0px;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2Sci2jXXXXXXFXpXXXXXXXXXX_!!2596264565.png\" size=\"611x442\">

      \"text-align:center;\">\"font-size:18.0px;\">璀璨钻石套餐包含【SK016D钥匙扣+GJ019C折叠刀+GJ017D工具卡】\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2wWohmXXXXXX8XXXXXXXXXXXX_!!2596264565.jpg\" size=\"750x600\" />

      \"text-align:center;\">\"font-size:18.0px;\">超凡大师套餐包括【304不锈钢钥匙扣+GJ019C折叠刀+GJ017D工具卡】\"//item.taobao.com/item.htm?id=520798805877\" target=\"_blank\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2_uiXnFXXXXXBXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"float:none;margin:0.0px;\" />

      \"text-align:center;\"

      \"text-align:center;\">\"font-size:18.0px;\">最强王者套餐包括【钛钢钥匙扣+GJ019C折叠刀+GJ017D工具卡】\"//item.taobao.com/item.htm?id=520801586805\" target=\"_blank\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2Gm9xnFXXXXbmXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"float:none;margin:0.0px;\" />

      \"text-align:center;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB28Ox4b77OyuJjSsplXXXqdpXa_!!2596264565.jpg\" size=\"749x553\"> \"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2.mTddVXXXXbeXpXXXXXXXXXX_!!2596264565.jpg\" style=\"line-height:1.5;\" size=\"750x653\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB21Ro.jl0lpuFjSszdXXcdxFXa_!!2596264565.jpg\" size=\"750x653\"> \"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2q9CelVXXXXcUXXXXXXXXXXXX_!!2596264565.jpg\" size=\"750x340\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB21EX9lVXXXXaXXpXXXXXXXXXX_!!2596264565.jpg\" size=\"750x416\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2udCylVXXXXXgXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2EARxjB8lpuFjSspaXXXJKpXa_!!2596264565.jpg\" size=\"750x515\"> \"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2ssuwlVXXXXafXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2nAHqgyC9MuFjSZFoXXbUzFXa_!!2596264565.jpg\" size=\"750x606\"> \"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2ahCelVXXXXc_XXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2w1JnjwRkpuFjy1zeXXc.6FXa_!!2596264565.jpg\" size=\"750x469\"> \"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2C902lVXXXXbnXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2sGR3lVXXXXblXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2ZBGxlVXXXXXMXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i1/2596264565/TB2MjWklVXXXXcaXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2UgV3lVXXXXbdXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2ip5XlVXXXXX2XpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\"> \"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2sMTBdVXXXXXlXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2d3HfdVXXXXahXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2AVbBdVXXXXXkXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2nf_wdVXXXXaMXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2dLYddVXXXXbtXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2H1_adVXXXXbWXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2eBzsdVXXXXbuXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i4/2596264565/TB2dOTndVXXXXcCXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB2fK2tdVXXXXbkXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i2/2596264565/TB29zjedVXXXXaFXpXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\">\"absmiddle\" src=\"//img.alicdn.com/imgextra/i3/2596264565/TB2i7rmdVXXXXcTXXXXXXXXXXXX_!!2596264565.jpg_q90.jpg\" style=\"line-height:1.5;\" />

      "
      ,
    26. "item_imgs": [
    27. {
    28. "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2p30elFXXXXXQXpXXXXXXXXXX_!!2596264565.jpg"
    29. },
    30. {
    31. "url": "//img.alicdn.com/imgextra/i2/2596264565/TB2onxRlVXXXXcDXpXXXXXXXXXX_!!2596264565.jpg"
    32. },
    33. {
    34. "url": "//img.alicdn.com/imgextra/i1/2596264565/TB2a.x.lVXXXXXPXpXXXXXXXXXX_!!2596264565.jpg"
    35. },
    36. {
    37. "url": "//img.alicdn.com/imgextra/i2/2596264565/TB2iWE6bKZkyKJjSszbXXblwFXa_!!2596264565.jpg"
    38. },
    39. {
    40. "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2j2cTXib_F1JjSZFzXXc6KXXa_!!2596264565.jpg"
    41. }
    42. ],
    43. "item_weight": "0",
    44. "item_size": "",
    45. "location": "广东深圳",
    46. "post_fee": "",
    47. "express_fee": "0.00",
    48. "ems_fee": "",
    49. "shipping_to": "广东广州白云区",
    50. "has_discount": "false",
    51. "video": [],
    52. "is_virtual": "",
    53. "sample_id": "",
    54. "is_promotion": "false",
    55. "props_name": "1627207:1347647754:颜色分类:长方形带开瓶器+送工具刀卡+链子;1627207:1347647753:颜色分类:椭圆形带开瓶器+送工具刀卡+链子;1627207:1195392087:颜色分类:GJ018X钥匙刀+送工具刀卡+链子;1627207:1331112595:颜色分类:超凡大师套餐【送工具卡+链子】;1627207:1331112594:颜色分类:最强王者套餐【送工具卡+链子】;1627207:1331264247:颜色分类:璀璨钻石套餐【送工具卡+链子】",
    56. "prop_imgs": {
    57. "prop_img": [
    58. {
    59. "properties": "1627207:1347647754",
    60. "url": "//img.alicdn.com/imgextra/i3/2596264565/TB2.XeblVXXXXXkXpXXXXXXXXXX_!!2596264565.jpg"
    61. },
    62. {
    63. "properties": "1627207:1347647753",
    64. "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2dTrjdVXXXXXBXpXXXXXXXXXX_!!2596264565.jpg"
    65. },
    66. {
    67. "properties": "1627207:1195392087",
    68. "url": "//img.alicdn.com/imgextra/i2/2596264565/TB2j22kdVXXXXXdXpXXXXXXXXXX_!!2596264565.jpg"
    69. },
    70. {
    71. "properties": "1627207:1331112595",
    72. "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2_uiXnFXXXXXBXXXXXXXXXXXX_!!2596264565.jpg"
    73. },
    74. {
    75. "properties": "1627207:1331112594",
    76. "url": "//img.alicdn.com/imgextra/i4/2596264565/TB2Gm9xnFXXXXbmXXXXXXXXXXXX_!!2596264565.jpg"
    77. },
    78. {
    79. "properties": "1627207:1331264247",
    80. "url": "//img.alicdn.com/imgextra/i3/2596264565/TB2wWohmXXXXXX8XXXXXXXXXXXX_!!2596264565.jpg"
    81. }
    82. ]
    83. },
    84. "property_alias": "1627207:1347647754:长方形带开瓶器+送工具刀卡+链子;1627207:1347647753:椭圆形带开瓶器+送工具刀卡+链子;1627207:1195392087:GJ018X钥匙刀+送工具刀卡+链子;1627207:1331112595:超凡大师套餐【送工具卡+链子】;1627207:1331112594:最强王者套餐【送工具卡+链子】;1627207:1331264247:璀璨钻石套餐【送工具卡+链子】",
    85. "props": [
    86. {
    87. "name": "品牌",
    88. "value": "三刃木"
    89. },
    90. {
    91. "name": "产地",
    92. "value": "中国"
    93. },
    94. {
    95. "name": "颜色分类",
    96. "value": "长方形带开瓶器+送工具刀卡+链子,椭圆形带开瓶器+送工具刀卡+链子,GJ018X钥匙刀+送工具刀卡+链子,超凡大师套餐【送工具卡+链子】,最强王者套餐【送工具卡+链子】,璀璨钻石套餐【送工具卡+链子】"
    97. },
    98. {
    99. "name": "吊牌价",
    100. "value": "46"
    101. },
    102. {
    103. "name": "功能数量",
    104. "value": "5个及以下"
    105. },
    106. {
    107. "name": "货号",
    108. "value": "GJ019C"
    109. },
    110. {
    111. "name": "附加功能",
    112. "value": "开瓶器,刀,螺丝刀,钥匙圈,其他"
    113. }
    114. ],
    115. "total_sold": "1",
    116. "skus": {
    117. "sku": [
    118. {
    119. "price": "39",
    120. "orginal_price": "39.00",
    121. "properties": "1627207:1347647754",
    122. "properties_name": "1627207:1347647754:颜色分类:长方形带开瓶器+送工具刀卡+链子",
    123. "quantity": "104",
    124. "sku_id": "3166598625985"
    125. },
    126. {
    127. "price": "39",
    128. "orginal_price": "39.00",
    129. "properties": "1627207:1347647753",
    130. "properties_name": "1627207:1347647753:颜色分类:椭圆形带开瓶器+送工具刀卡+链子",
    131. "quantity": "370",
    132. "sku_id": "3166598625984"
    133. },
    134. {
    135. "price": "25.8",
    136. "orginal_price": "25.80",
    137. "properties": "1627207:1195392087",
    138. "properties_name": "1627207:1195392087:颜色分类:GJ018X钥匙刀+送工具刀卡+链子",
    139. "quantity": "34",
    140. "sku_id": "3144644292458"
    141. },
    142. {
    143. "price": "73.8",
    144. "orginal_price": "73.80",
    145. "properties": "1627207:1331112595",
    146. "properties_name": "1627207:1331112595:颜色分类:超凡大师套餐【送工具卡+链子】",
    147. "quantity": "157",
    148. "sku_id": "3161300228970"
    149. },
    150. {
    151. "price": "91.8",
    152. "orginal_price": "91.80",
    153. "properties": "1627207:1331112594",
    154. "properties_name": "1627207:1331112594:颜色分类:最强王者套餐【送工具卡+链子】",
    155. "quantity": "0",
    156. "sku_id": "3161300228969"
    157. },
    158. {
    159. "price": "63.8",
    160. "orginal_price": "63.80",
    161. "properties": "1627207:1331264247",
    162. "properties_name": "1627207:1331264247:颜色分类:璀璨钻石套餐【送工具卡+链子】",
    163. "quantity": "167",
    164. "sku_id": "3161107666655"
    165. }
    166. ]
    167. },
    168. "seller_id": "2596264565",
    169. "sales": "1",
    170. "shop_id": "127203758",
    171. "props_list": {
    172. "1627207:1347647754": "颜色分类:长方形带开瓶器+送工具刀卡+链子",
    173. "1627207:1347647753": "颜色分类:椭圆形带开瓶器+送工具刀卡+链子",
    174. "1627207:1195392087": "颜色分类:GJ018X钥匙刀+送工具刀卡+链子",
    175. "1627207:1331112595": "颜色分类:超凡大师套餐【送工具卡+链子】",
    176. "1627207:1331112594": "颜色分类:最强王者套餐【送工具卡+链子】",
    177. "1627207:1331264247": "颜色分类:璀璨钻石套餐【送工具卡+链子】"
    178. },
    179. "seller_info": {
    180. "title": "欢乐购客栈",
    181. "shop_name": "欢乐购客栈",
    182. "sid": "127203758",
    183. "zhuy": "//shop127203758.taobao.com",
    184. "level": "12",
    185. "shop_type": "C",
    186. "user_num_id": "2596264565",
    187. "nick": "欢乐购客栈",
    188. "cid": null,
    189. "delivery_score": "4.8 ",
    190. "item_score": "4.8 ",
    191. "score_p": "4.8 "
    192. },
    193. "tmall": "false",
    194. "error": "",
    195. "warning": "",
    196. "url_log": [],
    197. "stuff_status": "",
    198. "shopinfo": {
    199. "shop_name": "欢乐购客栈",
    200. "shop_id": "127203758"
    201. },
    202. "data_from": "mtop",
    203. "method": "item_mtop:item_get",
    204. "promo_type": null,
    205. "props_img": {
    206. "1627207:1347647754": "//img.alicdn.com/imgextra/i3/2596264565/TB2.XeblVXXXXXkXpXXXXXXXXXX_!!2596264565.jpg",
    207. "1627207:1347647753": "//img.alicdn.com/imgextra/i4/2596264565/TB2dTrjdVXXXXXBXpXXXXXXXXXX_!!2596264565.jpg",
    208. "1627207:1195392087": "//img.alicdn.com/imgextra/i2/2596264565/TB2j22kdVXXXXXdXpXXXXXXXXXX_!!2596264565.jpg",
    209. "1627207:1331112595": "//img.alicdn.com/imgextra/i4/2596264565/TB2_uiXnFXXXXXBXXXXXXXXXXXX_!!2596264565.jpg",
    210. "1627207:1331112594": "//img.alicdn.com/imgextra/i4/2596264565/TB2Gm9xnFXXXXbmXXXXXXXXXXXX_!!2596264565.jpg",
    211. "1627207:1331264247": "//img.alicdn.com/imgextra/i3/2596264565/TB2wWohmXXXXXX8XXXXXXXXXXXX_!!2596264565.jpg"
    212. },
    213. "rate_grade": "",
    214. "shop_item": [],
    215. "relate_items": []
    216. },
    217. "secache": "d8bd20b8f0d9df02dd030dd374110240",
    218. "secache_time": 1591841298,
    219. "secache_date": "2020-06-11 10:08:18",
    220. "translate_status": "error",
    221. "translate_time": 0.001,
    222. "language": {
    223. "current_lang": "zh-CN",
    224. "source_lang": "cn"
    225. },
    226. "error": "",
    227. "reason": "",
    228. "error_code": "0000",
    229. "cache": 1,
    230. "api_info": "today:7033 max:10000",
    231. "execution_time": 0.211,
    232. "server_time": "Beijing/2020-06-11 10:12:27",
    233. "call_args": {
    234. "num_iid": "520813250866",
    235. "area_id": "440111"
    236. },
    237. "api_type": "taobao",
    238. "translate_language": "zh-CN",
    239. "translate_engine": "google_cn",
    240. "server_memory": "8.26MB",
    241. "request_id": "15ee1930b4e098"
    242. }

  • 相关阅读:
    【计算机网络】第三章课后习题答案
    CSS - 快速实现悬浮吸顶,当页面滑动一定距离时固定吸附在顶部(position: sticky)
    Vue进阶:组件化编程(脚手架) - 万字总结精华整理(持续更新)
    Redis数据类型之set
    [Linux] ssh远程访问及控制
    【windows Docker 安装mysql:只需3条命令】
    无线传感器网络:排队论(Queueing Theory)模型
    MyBatis的使用
    机器学习(五)逻辑回归
    一文了解企业云盘和大文件传输哪个更适合企业传输
  • 原文地址:https://blog.csdn.net/Anzexi123/article/details/126170897