instagram_api 0.0.3 → 0.0.4

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: 02de8a37a870ba8d1f221d49ee533744ac624cf6
4
- data.tar.gz: d1e0de12dbb95d30e22c6ef52ff3bf3eb660f1a4
3
+ metadata.gz: 9f7698eefcd07fb266f0fc98566f9c8b8075cb51
4
+ data.tar.gz: 01490aa9e40ddcd9f32a7199ad630833576d97d2
5
5
  SHA512:
6
- metadata.gz: 75b3721ddc83912c9c1df69e8c1c1610211cdef5b0fe26ea31fea5ff5aae86d5b251ed0120e71e4c5bdb2a581776a4d31de056cebf6d5c641c837c40bf362462
7
- data.tar.gz: 320fd03ce080700e9646709d2f348d7820dc876850d71d0610b627b2a0889bb86ffc9e8c60c97a7f96d97484d9d29c7000ceac6ead2dd8d7fb975ab9a65ac814
6
+ metadata.gz: 9b0ff3479a4d3c62edaf90be64569ae6f9f60d89cfd069a7181860656063cee9f323b984b0e7f33404ea57b2d5c7738467fec3df2289b2db3a9e7ebd59438927
7
+ data.tar.gz: 14dc82eb57ea8aa012efb579d485a4c4b7d6a75c37cf9817f78b41a08a5c2dc63b2c69bd67067bcdd5f540d67a6570f14d5435720129e4bfabddfe672c3f4fa0
data/.gitignore CHANGED
@@ -16,4 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  versions/
19
- spec/config.yml
19
+ spec/config.yml
20
+ examples/
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This gem is a simple and easy to use wrapper for Instagram's API.
4
4
 
5
+ ## Documentation
6
+
7
+ The documentation for this gem can be found at [rdoc.info/gems/instagram_api](http://rdoc.info/gems/instagram_api).
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
@@ -108,6 +112,73 @@ client.popular_media
108
112
 
109
113
  See the [Instagram Media Endpoints](http://instagram.com/developer/endpoints/media/) for more information.
110
114
 
115
+ ## Sample Application
116
+
117
+ The following is a sample application using this gem and [Sinatra](http://sinatrarb.com). Make sure that the sinatra and instagram_api gems are installed before running it.
118
+
119
+ ```bash
120
+ $ gem install sinatra instagram_api
121
+ ```
122
+
123
+ Afterwards, copy the contents of the following file into a file called sample.rb and add your client ID and client secret (retrieved by registering a new application at [http://instagram.com/developer](http://instagram.com/developer)).
124
+
125
+ ```ruby
126
+ require 'sinatra'
127
+ require 'instagram_api'
128
+
129
+ # Go to http://instagram.com/developer to get your client ID and client secret.
130
+ CLIENT_ID = "YOUR CLIENT ID"
131
+ CLIENT_SECRET = "YOUR CLIENT SECRET"
132
+
133
+ # Set the redirect uri for your application to the following:
134
+ REDIRECT_URI = "http://localhost:4567/callback"
135
+
136
+ client = Instagram.client(
137
+ :client_id => CLIENT_ID,
138
+ :client_secret => CLIENT_SECRET,
139
+ :callback_url => REDIRECT_URI
140
+ )
141
+
142
+ get '/' do
143
+ output = '<h2>Popular Media</h2>'
144
+ client.popular_media.data.each do |p|
145
+ output << "<a href='#{p.link}'><img src='#{p.images.thumbnail.url}'></a>&nbsp;"
146
+ end
147
+ output << '<br /><h3><a href="/auth">Click here</a> to authenticate with Instagram.</h3>'
148
+ output
149
+ end
150
+
151
+ get '/auth' do
152
+ redirect client.authorize_url
153
+ end
154
+
155
+ get '/callback' do
156
+ client.get_access_token(params[:code])
157
+ redirect '/dashboard'
158
+ end
159
+
160
+ get '/dashboard' do
161
+ user = client.user
162
+ output = "<h2>#{user.data.username}'s feed</h2>"
163
+ client.feed.data.each do |f|
164
+ output << "<a href='#{f.link}'><img src='#{f.images.low_resolution.url}'></a><br />
165
+ <img src='#{f.user.profile_picture}' width='20'>&nbsp;#{f.user.username}<br /><br />"
166
+ end
167
+ output
168
+ end
169
+ ```
170
+
171
+ You can then run the application by issuing the following command from the file's directory:
172
+
173
+ ```bash
174
+ $ ruby sample.rb
175
+ ```
176
+
177
+ Then navigate to [localhost:4567](http://localhost:4567) to see the application in action.
178
+
179
+ You can view/download this file [here](https://gist.github.com/caseyscarborough/6331272).
180
+
181
+
111
182
  ## Contributing
112
183
 
113
184
  1. Fork it
@@ -28,10 +28,15 @@ module Instagram
28
28
  # @see http://instagram.com/developer/endpoints/media/#get_media_search
29
29
  # @example Perform a search based on latitude and longitude.
30
30
  # client.media_search(:lat => "48.858844", :lng => "2.294351")
31
- # @example Search within 2km.
32
- # client.media_search(:distance => 2000)
33
- # @example Search by timestamp.
34
- # client.media_search(:min_timestamp => 1357020000, :max_timestamp => 1375246800)
31
+ # @example Search within 2km of a location.
32
+ # client.media_search(:lat => "48.858844", :lng => "2.294351", :distance => 2000)
33
+ # @example Constrain results by timestamp.
34
+ # client.media_search(
35
+ # :lat => "48.858844",
36
+ # :lng => "2.294351",
37
+ # :min_timestamp => 1357020000,
38
+ # :max_timestamp => 1375246800
39
+ # )
35
40
  def media_search(options={})
36
41
  get '/media/search', auth_params.merge(options)
37
42
  end
@@ -1,3 +1,3 @@
1
1
  module Instagram
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instagram_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey Scarborough