Skip to content

Commit 923eb1e

Browse files
authored
Merge pull request #101 from Fullscreen/revert-app-token-by-request
revert 'Use App Access Token generated by GET for all API requests'
2 parents f33c682 + 24bc5ba commit 923eb1e

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ For more information about changelogs, check
66
[Keep a Changelog](http://keepachangelog.com) and
77
[Vandamme](http://tech-angels.github.io/vandamme).
88

9+
## 0.2.31 - 2017/10/25
10+
11+
* [BUGFIX] Revert the change of version 0.2.29 and do not use request to get app
12+
access token.
13+
* [ENHANCEMENT] Allow funky to scrape view count for more videos, by changing
14+
the way how to scrape.
15+
916
## 0.2.30 - 2017/10/16
1017

1118
* [BUGFIX] Test should pass when call Page#videos. Partly revert the change

lib/funky/connections/api.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Funky
88
module Connection
99
class API < Base
1010
def self.fetch_all(path_query)
11-
uri = URI "https://#{host}/v2.9/#{path_query}&limit=100&access_token=#{app_access_token}"
11+
uri = URI "https://#{host}/v2.9/#{path_query}&limit=100&access_token=#{app_id}%7C#{app_secret}"
1212
fetch_data_with_paging_token(uri)
1313
end
1414

@@ -24,7 +24,7 @@ def self.fetch_data_with_paging_token(uri)
2424
end
2525

2626
def self.fetch(path_query, is_array: false)
27-
uri = URI "https://#{host}/v2.8/#{path_query}&limit=100&access_token=#{app_access_token}"
27+
uri = URI "https://#{host}/v2.8/#{path_query}&limit=100&access_token=#{app_id}%7C#{app_secret}"
2828
is_array ? fetch_multiple_pages(uri).uniq : json_for(uri)
2929
rescue URI::InvalidURIError
3030
raise Funky::ContentNotFound, "Invalid URL"
@@ -66,14 +66,14 @@ def self.fetch_multiple_pages(uri)
6666
def self.request(id:, fields:)
6767
uri = URI::HTTPS.build host: host,
6868
path: "/v2.8/#{id}",
69-
query: "access_token=#{app_access_token}&fields=#{fields}"
69+
query: "access_token=#{app_id}%7C#{app_secret}&fields=#{fields}"
7070
response_for(get_http_request(uri), uri)
7171
end
7272

7373
def self.batch_request(ids:, fields:)
7474
uri = URI::HTTPS.build host: host,
7575
path: "/",
76-
query: "include_headers=false&access_token=#{app_access_token}"
76+
query: "include_headers=false&access_token=#{app_id}%7C#{app_secret}"
7777
batch = create_batch_for ids, fields
7878
http_request = post_http_request uri
7979
http_request.set_form_data batch: batch.to_json
@@ -94,14 +94,6 @@ def self.app_secret
9494
Funky.configuration.app_secret
9595
end
9696

97-
def self.app_access_token
98-
@app_access_token ||= begin
99-
uri = URI::HTTPS.build host: host, path: "/v2.8/oauth/access_token",
100-
query: URI.encode_www_form({client_id: app_id, client_secret: app_secret, grant_type: 'client_credentials'})
101-
Funky::Connection::API.json_for(uri)[:access_token]
102-
end
103-
end
104-
10597
def self.post_http_request(uri)
10698
Net::HTTP::Post.new uri
10799
end

lib/funky/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Funky
2-
VERSION = "0.2.30"
2+
VERSION = "0.2.31"
33
end

0 commit comments

Comments
 (0)