Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'upstream/master' into current

  • Loading branch information...
commit b8ebff531c117b5fbb52a0acb28ada90508bef21 2 parents 7f79aca + 4f56fd8
@3ft9 3ft9 authored
Showing with 6 additions and 8 deletions.
  1. +1 −1  README.md
  2. +0 −1  datasift.gemspec
  3. +5 −6 lib/DataSift/apiclient.rb
View
2  README.md
@@ -16,7 +16,7 @@ Dependencies
If you're using the source you'll need to install the dependencies.
-sudo gem install yajl-ruby json rest-client
+sudo gem install yajl-ruby rest-client
Simple example
--------------
View
1  datasift.gemspec
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
s.add_runtime_dependency('rest-client', '~> 1.6.3')
- s.add_runtime_dependency('json', '~> 1')
s.add_runtime_dependency('yajl-ruby', '~> 0.8.2')
s.add_development_dependency('rdoc', '~> 0')
s.add_development_dependency('shoulda', '~> 2.11.3')
View
11 lib/DataSift/apiclient.rb
@@ -9,7 +9,7 @@
# DataSift API.
require 'rest_client'
-require 'json'
+require 'yajl'
module DataSift
# ApiCLient class.
@@ -29,7 +29,7 @@ class ApiClient
# * +api_key+ - The API key for the Auth header
def call(username, api_key, endpoint, params = {}, user_agent = 'DataSiftPHP/0.0')
# Build the full endpoint URL
- url = 'http://' + User::API_BASE_URL + endpoint + '.json?' + hashToQuerystring(params)
+ url = 'http://' + User::API_BASE_URL + endpoint
retval = {
'response_code' => 500,
@@ -40,14 +40,13 @@ def call(username, api_key, endpoint, params = {}, user_agent = 'DataSiftPHP/0.0
begin
# Make the call
- res = RestClient.get(url, { 'Auth' => username + ':' + api_key, 'User-Agent' => user_agent })
+ res = RestClient.post(url, params, { 'Auth' => username + ':' + api_key, 'User-Agent' => user_agent })
# Success
retval['response_code'] = 200
# Parse the JSON response
- retval['data'] = JSON.parse(res)
-
+ retval['data'] = Yajl::Parser.parse(res)
# Rate limit headers
if (res.headers[:x_ratelimit_limit])
retval['rate_limit'] = res.headers[:x_ratelimit_limit]
@@ -61,7 +60,7 @@ def call(username, api_key, endpoint, params = {}, user_agent = 'DataSiftPHP/0.0
retval['response_code'] = err.http_code
# And set the data
- retval['data'] = JSON.parse(err.response)
+ retval['data'] = Yajl::Parser.parse(err.response)
end
retval
Please sign in to comment.
Something went wrong with that request. Please try again.