httpclient 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +0,0 @@
1
- require 'httpclient'
2
-
3
- # Obtain Personal access token from https://github.com/settings/applications
4
- personal_access_token = '03d1c4bc880e51c06215cc77eb075a7856e6a9c7'
5
-
6
- h = HTTPClient.new
7
- h.set_auth(nil, personal_access_token, 'x-oauth-basic')
8
- h.www_auth.basic_auth.challenge('https://api.github.com/')
9
- h.debug_dev = STDERR
10
-
11
- puts h.get_content('https://api.github.com/user/repos?type=private')
@@ -1,63 +0,0 @@
1
- require 'oauthclient'
2
-
3
- # Get your own consumer token from http://twitter.com/apps
4
- consumer_key = '3MVG9y6x0357HledNGHa9tJrrlOmpCSo5alTv4W4AG1M0f9a8cGBIwo5wN2bQ7hjAEsjD7SBWf3H2Oycc9Qql'
5
- consumer_secret = '1404017425765973464'
6
-
7
- callback = ARGV.shift # can be nil for OAuth 1.0. (not 1.0a)
8
- request_token_url = 'https://login.salesforce.com/_nc_external/system/security/oauth/RequestTokenHandler'
9
- oob_authorize_url = 'https://login.salesforce.com/setup/secur/RemoteAccessAuthorizationPage.apexp'
10
- access_token_url = 'https://login.salesforce.com/_nc_external/system/security/oauth/AccessTokenHandler'
11
-
12
- STDOUT.sync = true
13
-
14
- # create OAuth client.
15
- client = OAuthClient.new
16
- client.oauth_config.consumer_key = consumer_key
17
- client.oauth_config.consumer_secret = consumer_secret
18
- client.oauth_config.signature_method = 'HMAC-SHA1'
19
- client.oauth_config.http_method = :get # Twitter does not allow :post
20
- client.debug_dev = STDERR if $DEBUG
21
-
22
- client.ssl_config.ssl_version = "TLSv1_1"
23
-
24
- # Get request token.
25
- res = client.get_request_token(request_token_url, callback)
26
- p res.status
27
- p res.oauth_params
28
- p res.content
29
- p client.oauth_config
30
- token = res.oauth_params['oauth_token']
31
- secret = res.oauth_params['oauth_token_secret']
32
- raise if token.nil? or secret.nil?
33
-
34
- # You need to confirm authorization out of band.
35
- puts
36
- puts "Go here and do confirm: #{oob_authorize_url}?oauth_token=#{token}&oauth_consumer_key=#{consumer_key}"
37
- puts "Type oauth_verifier/PIN (if given) and hit [enter] to go"
38
- verifier = gets.chomp
39
- verifier = nil if verifier.empty?
40
-
41
- # Get access token.
42
- # FYI: You may need to re-construct OAuthClient instance here.
43
- # In normal web app flow, getting access token and getting request token
44
- # must be done in different HTTP requests.
45
- # client = OAuthClient.new
46
- # client.oauth_config.consumer_key = consumer_key
47
- # client.oauth_config.consumer_secret = consumer_secret
48
- # client.oauth_config.signature_method = 'HMAC-SHA1'
49
- # client.oauth_config.http_method = :get # Twitter does not allow :post
50
- res = client.get_access_token(access_token_url, token, secret, verifier)
51
- p res.status
52
- p res.oauth_params
53
- p res.content
54
- p client.oauth_config
55
- id = res.oauth_params['user_id']
56
-
57
- puts
58
- puts "Access token usage example"
59
- puts "Hit [enter] to go"
60
- gets
61
-
62
- # Access to a protected resource. (DM)
63
- puts client.get("http://twitter.com/direct_messages.json")
@@ -1,11 +0,0 @@
1
- http = HTTPClient.new
2
-
3
- p http.debug_dev
4
-
5
- http.debug_dev = STDOUT
6
- file = File.open("api_rest.pdf")
7
- class <<file
8
- undef :size
9
- end
10
- result = http.post('http://www.google.com/', file, {"Content-Type" => 'audio/wav'})
11
- p result