sitoto / jd-union

jd union api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JD::Union

A simple ruby implementation of JD Union API 京东联盟API

Installation

gem 'jd-union', '0.0.1', git: 'https://github.com/sitoto/jd-union.git'

Usage

require 'jd/union'
material_url = "https://item.jd.com/****.html"
jd_query = {promotionCodeReq: {materialId: material_url,siteId: JD_UNION_SITE_ID,positionId: JD_UNION_SITE_POSITION_ID}}
service = JD::Union::Service.new(JD_UNION_APP_KEY, JD_UNION_APP_SECRET) do |options|
  options.format = "json"
  options.sign_method = "md5"
  options.param_json = JSON(jd_query)
end
response = service.get("jd.union.open.promotion.common.get")
@result = response
unless response.errorResponse?
  result = response.body.result
  result = JSON.parse(result)
  @code = result['code']
  @click_url = result['data']['clickURL']
else
  p response.errorResponse.code
  p response.errorResponse.msg
end

Contributing

References

Taobao::TOP

About

jd union api

License:MIT License


Languages

Language:Ruby 100.0%