yahoo-api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fd3910f79d48d1ac0860545fc252aaea3342ffd
4
- data.tar.gz: a79cb0bd89a4e3c57c09f80bf23d29fe2a42653f
3
+ metadata.gz: f7ecfc2b6df75048e6cbc30ee85783f2b0ebaef2
4
+ data.tar.gz: a439d5d50a0996131cbb8602483a94eae7284ac8
5
5
  SHA512:
6
- metadata.gz: 07c2fb333b8f6f0984a91e49fef59f95667591f7fd118ca11dec1a54a6c930009d36c424d8a6c179bcd9e6ea792446e8a2d682c7e83cf088070c057477c20175
7
- data.tar.gz: 98fc8dea5ee95a9bc289367636fc2203796fd2f375f07918b14e3e9a7012b726bceee3945c98550fc2c6fd56511d2c1a6f33a4aae81b028148406938761cda8c
6
+ metadata.gz: 64f9f8db9ab1a6794c00c637bbe550f471cced5a4f3e4be59fdcf603ae8435f5c7da36b3e1bc13995e5136668e26a2460791f86494e74d10492192402c73ee47
7
+ data.tar.gz: 8e7d698f9f1dfeba0cfbe62aaa84f9a6896f009775b5989fb2b54b77c2e18269db53f6e2b83669d01c835220a77679e86f06e06e5c1f7f5d64d0f9f53f534534
data/README.md CHANGED
@@ -19,58 +19,112 @@ Or install it yourself as:
19
19
 
20
20
  ## Usage
21
21
 
22
+ ### Configure
23
+
24
+ Yahoo::Api.configure do |options|
25
+ options[:appid] = 'your api id'
26
+ options[:affiliate_type] = "vc or yid"
27
+ options[:affiliate_id] = "your affiliate id"
28
+ end
29
+
22
30
  ### Yahoo Shopping API
23
31
 
24
- Yahoo Shopping Item Search API v1
32
+ Item Search API v1
25
33
 
26
- res = Yahoo::Api::Shopping.item_search({:category_id => 13457})
34
+ res = Yahoo::Api::Shopping.item_search({:category_id => "13457"})
27
35
  res.code # 200
28
36
  res.message # "OK"
29
- res["ResultSet"]["totalResultsReturned"].times
30
37
 
31
- Yahoo Shopping Category Ranking API v1
32
- def category_ranking(opts={})
33
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/categoryRanking", opts.merge(Yahoo::Api.options))
38
+ res["ResultSet"]["totalResultsReturned"].times do |i|
39
+ code = res["ResultSet"]["0"]["Result"]["#{i}"]["Code"]
40
+ ...
34
41
  end
35
42
 
36
- Yahoo Shopping Category Search API v1
37
- def category_search(opts={})
38
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/categorySearch", opts.merge(Yahoo::Api.options))
43
+ or
44
+
45
+ res["ResultSet"]["0"]["Result"].each do |i,v|
46
+ next unless i =~ /\d+/
47
+ code = v["Code"]
48
+ ...
39
49
  end
40
50
 
41
- Yahoo Shopping Item Lookup API v1
42
- def item_lookup(opts={})
43
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/itemLookup", opts.merge(Yahoo::Api.options))
51
+ Category Ranking API v1
52
+
53
+ res = Yahoo::Api::Shopping.category_ranking({:category_id => "13457"})
54
+ res["ResultSet"]["totalResultsReturned"].times do |i|
55
+ code = res["ResultSet"]["0"]["Result"]["#{i}"]["Code"]
56
+ ...
44
57
  end
45
58
 
46
- Yahoo Shopping Query Ranking API v1
47
- def query_ranking(opts={})
48
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/queryRanking", opts.merge(Yahoo::Api.options))
59
+ Category Search API v1
60
+
61
+ res = Yahoo::Api::Shopping.category_search({:category_id => "1"})
62
+ res["ResultSet"]["0"]["Result"]["Categories"]["Children"].each do |i,v|
63
+ next unless i =~ /\d+/
64
+ id = v["Id"]
65
+ ...
49
66
  end
50
67
 
51
- Yahoo Shopping Content Match Item API v1
52
- def content_match_item(opts={})
53
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/contentMatchItem", opts.merge(Yahoo::Api.options))
68
+ Item Lookup API v1
69
+
70
+ res = Yahoo::Api::Shopping.item_lookup({:itemcode => "hair_haclm352nn"})
71
+ res["ResultSet"]["0"]["Result"].each do |i,v|
72
+ next unless i =~ /\d+/
73
+ name = v["Name"]
74
+ ...
54
75
  end
55
76
 
56
- Yahoo Shopping Content Match Ranking API v1
57
- def content_match_ranking(opts={})
58
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/contentMatchRanking", opts.merge(Yahoo::Api.options))
77
+ Query Ranking API v1
78
+
79
+ res = Yahoo::Api::Shopping.query_ranking({:category_id => "13457"})
80
+ res["ResultSet"]["0"]["Result"].each do |i,v|
81
+ next unless i =~ /\d+/
82
+ url = v["Url"]
83
+ ...
59
84
  end
60
85
 
61
- Yahoo Shopping Get Module API v1
62
- def get_module(opts={})
63
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/getModule", opts.merge(Yahoo::Api.options))
86
+ Content Match Item API v1
87
+
88
+ res = Yahoo::Api::Shopping.content_match_item({:url => "http://www.yahoo.co.jp/"})
89
+ res["ResultSet"]["0"]["Result"].each do |i,v|
90
+ next unless i =~ /\d+/
91
+ name = v["Name"]
92
+ ...
64
93
  end
65
94
 
66
- Yahoo Shopping Event Search API v1
67
- def event_search(opts={})
68
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/eventSearch", opts.merge(Yahoo::Api.options))
95
+ Content Match Ranking API v1
96
+
97
+ res = Yahoo::Api::Shopping.content_match_ranking({:url => "http://www.yahoo.co.jp/"})
98
+ res["ResultSet"]["0"]["Result"].each do |i,v|
99
+ next unless i =~ /\d+/
100
+ name = v["Name"]
101
+ ...
102
+ end
103
+
104
+ Get Module API v1
105
+
106
+ res = Yahoo::Api::Shopping.get_module({:category_id => "13457",:position => "eventrecommend"})
107
+ res["ResultSet"]["0"]["Result"].each do |i,v|
108
+ next unless i =~ /\d+/
109
+ title = v["Title"]
110
+ ...
69
111
  end
70
112
 
71
- Yahoo Shopping Review Search API v1
72
- def review_search(opts={})
73
- Request.get("http://shopping.yahooapis.jp/ShoppingWebService/V1/json/reviewSearch", opts.merge(Yahoo::Api.options))
113
+ Event Search API v1
114
+
115
+ res = Yahoo::Api::Shopping.event_search({:event_type => "store"})
116
+ res["ResultSet"]["0"]["Result"].each do |i,v|
117
+ next unless i =~ /\d+/
118
+ code = v["EventCode"]
119
+ ...
120
+ end
121
+
122
+ Review Search API v1
123
+
124
+ res = Yahoo::Api::Shopping.review_search({:category_id => "13457"})
125
+ res["ResultSet"]["Result"].each do |v|
126
+ code = v["Target"]["Code"]
127
+ ...
74
128
  end
75
129
 
76
130
  ### Yahoo Auction API
@@ -1,5 +1,6 @@
1
1
  require "net/http"
2
2
  require "uri"
3
+ require "cgi"
3
4
  require "json"
4
5
  require "yahoo/api/version"
5
6
  require "yahoo/api/response"
@@ -28,4 +29,4 @@ module Yahoo
28
29
 
29
30
  end
30
31
 
31
- end
32
+ end
@@ -3,7 +3,7 @@ module Yahoo
3
3
  class Request
4
4
 
5
5
  def self.get(path,opts)
6
- uri = URI.parse("#{path}?#{opts.map {|k,v|"#{k}=#{URI.encode(v)}"}.join('&')}")
6
+ uri = URI.parse("#{path}?#{opts.map {|k,v|"#{k}=#{CGI.escape(v)}"}.join('&')}")
7
7
  Yahoo::Response.new(Net::HTTP.get_response(uri))
8
8
  end
9
9
 
@@ -27,4 +27,4 @@ module Yahoo
27
27
 
28
28
  end
29
29
 
30
- end
30
+ end
@@ -62,4 +62,4 @@ module Yahoo
62
62
 
63
63
  end
64
64
 
65
- end
65
+ end
@@ -1,5 +1,5 @@
1
1
  module Yahoo
2
2
  class Api
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
- end
5
+ end
data/test.rb CHANGED
@@ -1,5 +1,69 @@
1
1
  require "yahoo/api"
2
- res = Yahoo::Api::Shopping.item_search({:category_id => 13457})
3
- p res.code # 200
4
- p res.message # "OK"
5
- #res["ResultSet"]["totalResultsReturned"].times
2
+ Yahoo::Api.configure do |options|
3
+ options[:appid] = 'dj0zaiZpPVBzbEY1RWlSNVd2biZzPWNvbnN1bWVyc2VjcmV0Jng9MTU-'
4
+ end
5
+
6
+ # http://shopping.yahooapis.jp/ShoppingWebService/V1/json/reviewSearch?appid=dj0zaiZpPVBzbEY1RWlSNVd2biZzPWNvbnN1bWVyc2VjcmV0Jng9MTU-&category_id=13457
7
+ res = Yahoo::Api::Shopping.review_search({:category_id => "13457"})
8
+ # p res["ResultSet"]["Result"][]
9
+ res["ResultSet"]["Result"].each do |v|
10
+ # next unless i =~ /\d+/
11
+ p code = v["Target"]["Code"]
12
+ end
13
+ # res = Yahoo::Api::Shopping.event_search({:event_type => "store"})
14
+ # res["ResultSet"]["0"]["Result"].each do |i,v|
15
+ # next unless i =~ /\d+/
16
+ # p code = v["EventCode"]
17
+ # end
18
+ # res = Yahoo::Api::Shopping.get_module({:category_id => "13457",:position => "eventrecommend"})
19
+ # res["ResultSet"]["0"]["Result"].each do |i,v|
20
+ # next unless i =~ /\d+/
21
+ # p title = v["Title"]
22
+ # end
23
+
24
+ # res = Yahoo::Api::Shopping.content_match_ranking({:url => "http://www.yahoo.co.jp/"})
25
+ # res["ResultSet"]["0"]["Result"].each do |i,v|
26
+ # next unless i =~ /\d+/
27
+ # p name = v["Name"]
28
+ # end
29
+ # res = Yahoo::Api::Shopping.content_match_item({:url => "http://www.yahoo.co.jp/"})
30
+ # res["ResultSet"]["0"]["Result"].each do |i,v|
31
+ # next unless i =~ /\d+/
32
+ # p name = v["Name"]
33
+ # end
34
+ # res = Yahoo::Api::Shopping.query_ranking({:category_id => "13457"})
35
+ # res["ResultSet"]["0"]["Result"].each do |i,v|
36
+ # next unless i =~ /\d+/
37
+ # p url = v["Url"]
38
+ # end
39
+ # res = Yahoo::Api::Shopping.item_lookup({:itemcode => "hair_haclm352nn"})
40
+ # res["ResultSet"]["0"]["Result"].each do |i,v|
41
+ # next unless i =~ /\d+/
42
+ # p name = v["Name"]
43
+ # end
44
+ # res = Yahoo::Api::Shopping.category_search({:category_id => "1"})
45
+ # res["ResultSet"]["0"]["Result"]["Categories"]["Children"].each do |k,v|
46
+ # p id = v["Id"]
47
+ # next if id.nil?
48
+ # end
49
+ # # 0.times{|i| p i}
50
+
51
+ # res = Yahoo::Api::Shopping.category_ranking({:category_id => "13457"})
52
+ # res.code # 200
53
+ # res.message # "OK"
54
+ # res["ResultSet"]["0"]["Result"].each do |i,v|
55
+ # next unless i =~ /\d+/
56
+ # p v["Code"]
57
+ # end
58
+ # res["ResultSet"]["totalResultsReturned"].times do |i|
59
+ # p res["ResultSet"]["0"]["Result"]["#{i}"]["Code"]
60
+ # end
61
+
62
+
63
+ # res = Yahoo::Api::Shopping.item_search({:category_id => "13457"})
64
+ # p res.code # 200
65
+ # p res.message # "OK"
66
+ # res["ResultSet"]["totalResultsReturned"].times do |i|
67
+ # p res["ResultSet"]["0"]["Result"]["#{i}"]["Code"]
68
+ # end
69
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - shoprev