Giter VIP home page Giter VIP logo

poke-api's People

Contributors

diemer avatar dphuang2 avatar emcmanus avatar ggmichaelgo avatar nabeelamjad avatar penchef avatar xssc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poke-api's Issues

S2 geometry library porting

@nabeelamjad
The S2 geometry cells which are natively implemented in ruby will be very helpful in my project. The Lat-Long to cell id conversion code is ported from the S2 Geometry library. But the cell id to lat-long conversion is not available in this gem.
Can you help me to port the rest of the library? And guide me with the required resources for porting the library?

store_location needed?

Hi,

is store_location needed? It's in all your examples but I am just wondering if it is required/expected or if I can simply skip it?

Thanks!!

Trying to understand fetch_ticket

I am trying to understand this (https://github.com/nabeelamjad/poke-api/blob/master/lib/poke-api/auth/ptc.rb):

        def fetch_ticket(data)
          logger.debug '[>] Fetching PTC ticket'

          ticket = begin
            @client.post_content(PTC_LOGIN_URL, data)
          rescue StandardError => ex
            ex.res.http_header.request_uri.to_s.match(/ticket=(.*)/)[1]
          end

          fetch_access_token(ticket)
        end

I'm tried running the code individually. It seems httpclient lib fails unexpectedly, thats why you need the begin block there. The ticket is used to generate the access token on the next method.

Doing the same thing on httparty (another http gem), doesnt render any errors:

Take for example:

JSON.parse(
  HTTParty.post(
    ptc_login_url,
    headers: {
      'agent_name' => 'PokeAPI/0.0.1'
    },
    body: {
      data: {
        username: 'some_username',
        password: 'password',
        _eventId: 'submit',
        lt: json_response['lt'],
        execution: json_response['execution']
      }
    }
  )
)

However, the response I get instead is {"lt"=>"LT-23868518-ohkebxUhorQIFc11V3441qrSMOhFdF", "execution"=>"e1s1"}

Instead of what you currently need for the ticket: ST-7486015-NGPOWEQLoxc2mJM4flun-sso.pokemon.com

Am I missing something with the HTTParty approach?

403

Hi @nabeelamjad, any idea what Poke::API::Errors::ForbiddenAccess - Your host is unable to receive a response as it is banned. means/how it can be fixed?

get_map_objects always returns with empty pokemon arrays

Not sure if I am getting this.

I do something like:

require 'poke-api'
require 'awesome_print'

# Instantiate our client
client = Poke::API::Client.new

# Both PTC/Google available as authentication provider
client.store_location('New York')
client.store_lat_lng(40.712906, -74.007333) # Some random coordinates from NY (pulled from Google Maps)

client.login('some_username', 'password_here', 'ptc')

cell_ids = Poke::API::Helpers.get_cells(client.lat, client.lng)

# Construct map objects call
client.get_map_objects(
  latitude: client.lat,
  longitude: client.lng,
  since_timestamp_ms: [0] * cell_ids.length,
  cell_id: cell_ids
)

resp = client.call

puts resp.response

All I get are responses with no results:

            [ 0] {
                            :s2_cell_id => some_cell_id_here,
                  :current_timestamp_ms => 1470811515476,
                                 :forts => [],
                          :spawn_points => [],
                         :wild_pokemons => [],
                       :deleted_objects => [],
                     :is_truncated_list => false,
                        :fort_summaries => [],
                :decimated_spawn_points => [],
                    :catchable_pokemons => [],
                       :nearby_pokemons => []
            },

As in wild_pokemons, catchable_pokemons and nearby_pokemons always returns with an empty array []. Is there something I am missing?

re-login fails repeatedly

I am creating an instance of Poke::API::Client and logging in, if it fails, and I try to re-log in, it fails continuously unless I create a new instance, I would try to help further but I had no luck getting it to fail when I turn logs to debug (tried for like 15 mins)

wrong S2 cell ID for given latitude and longitude

(main)> require 'poke-api'
=> true
(main)> lat = -23.59260639636282
=> -23.59260639636282
(main)> lng = -46.680191904206524
=> -46.680191904206524
(main)> Poke::API::Helpers.get_cells(lat, lng)
=> [
    [ 0] 10722603741376151552,
    [ 1] 10722603743523635200,
    [ 2] 10722603745671118848,
    [ 3] 10722603747818602496,
    [ 4] 10722603749966086144,
    [ 5] 10722603752113569792,
    [ 6] 10722603754261053440,
    [ 7] 10722603756408537088,
    [ 8] 10722603758556020736,
    [ 9] 10722603760703504384,
    [10] 10722603762850988032,
    [11] 10722603764998471680,
    [12] 10722603767145955328,
    [13] 10722603769293438976,
    [14] 10722603771440922624,
    [15] 10722603773588406272,
    [16] 10722603775735889920,
    [17] 10722603777883373568,
    [18] 10722603780030857216,
    [19] 10722603782178340864,
    [20] 10722603784325824512
]

which does not contain the S2 Cell ID 10722603763924729856, whose center is lat, lng.

Contrast this with sidewalklabs/s2sphere: Python implementation of the S2 geometry library:

>>> import s2sphere
>>> lat = -23.59260639636282
>>> lng = -46.680191904206524
>>> cell = s2sphere.Cell.from_lat_lng(s2sphere.LatLng.from_degrees(lat, lng))
>>> cell.id().parent(12).id()
10722603763924729856

Heroku deployment login issue

Logging in with the API locally on my computer yields no errors. But when I try to use it on Heroku's servers I get this error.

Loading production environment (Rails 5.0.0)
irb(main):001:0> client = Poke::API::Client.new
=> #<Poke::API::Client @auth= @reqs=[] @lat=0 @lng=0 @alt=0>
irb(main):002:0> client.login("xxx","xxx","ptc")
[2016-07-31T04:49:03+00:00]: INFO  > Poke::API::Client         --: [+] Logging in user: xxx
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::Client         --: [+] Login with PTC Successful
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::RequestBuilder --: [+] Adding 'GET_PLAYER' to RPC request
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::RequestBuilder --: [+] Adding 'GET_HATCHED_EGGS' to RPC request
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::RequestBuilder --: [+] Adding 'GET_INVENTORY' to RPC request
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::RequestBuilder --: [+] Adding 'CHECK_AWARDED_BADGES' to RPC request
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::RequestBuilder --: [+] Adding 'DOWNLOAD_SETTINGS' to RPC request with arguments
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::RequestBuilder --: [+] Executing RPC request
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::Response       --: [+] Decoding Main RPC responses
[2016-07-31T04:49:04+00:00]: INFO  > Poke::API::Client         --: [+] Cleaning up RPC requests
Poke::API::Errors::UnknownProtoFault: An unknown proto fault has occured => [Error occurred during parsing: Unmatched ENDGROUP tag. @ /app/vendor/bundle/ruby/2.2.0/bundler/gems/poke-api-85ee2d01f869/lib/poke-api/response.rb:14:in `decode']
    from /app/vendor/bundle/ruby/2.2.0/bundler/gems/poke-api-85ee2d01f869/lib/poke-api/client.rb:39:in `rescue in call'
    from /app/vendor/bundle/ruby/2.2.0/bundler/gems/poke-api-85ee2d01f869/lib/poke-api/client.rb:43:in `call'
    from /app/vendor/bundle/ruby/2.2.0/bundler/gems/poke-api-85ee2d01f869/lib/poke-api/client.rb:70:in `fetch_endpoint'
    from /app/vendor/bundle/ruby/2.2.0/bundler/gems/poke-api-85ee2d01f869/lib/poke-api/client.rb:29:in `login'
    from (irb):2
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0/lib/rails/commands/console.rb:65:in `start'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0/lib/rails/commands/console_helper.rb:9:in `start'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:78:in `console'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:9:in `require'
    from bin/rails:9:in `<main>'
irb(main):003:0>

To replicate this error you have to make a Rails project and client.login through Heroku console (accessed by "heroku run console"). I don't know if this is a problem with the API, my development environment, or with heroku itself. But I have tried to figure this out for a while and have gotten nowhere. If anyone has any insight to Rails deployment to Heroku and possible culprits that would be great.

I am using Ruby 2.2.4 and Rails 5.0 and have tried deploying with Ruby 2.2.4 to no avail.

Getting unknown type: size_t input_size

Currently getting:

/Users/foo/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/poke-go-api-0.1.7/lib/poke-api/client.rb:44:in `rescue in call': An unknown proto fault has occured => [unknown type: size_t input_size @ /Users/foo/.rbenv/versions/2.2.5/lib/ruby/2.2.0/fiddle/cparser.rb:171:in `parse_ctype'] (Poke::API::Errors::UnknownProtoFault)
        from /Users/foo/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/poke-go-api-0.1.7/lib/poke-api/client.rb:48:in `call'

This just suddenly appeared. Im guessing due to PoGo API update?

Encryption

Hey

What is encryption file and how i can get it?

undefined method `to_h' for [["error", "invalid_grant"]]:Array

Poke::API::Errors::LoginFailure: Unable to login to PTC => [undefined method to_h' for [["error", "invalid_grant"]]:Array @ /Users/user/.rbenv/versions/2.0.0-p645/lib/ruby/gems/2.0.0/bundler/gems/poke-api-fd27b2c9834f/lib/poke-api/auth/ptc.rb:65:infetch_access_token']
from /Users/user/.rbenv/versions/2.0.0-p645/lib/ruby/gems/2.0.0/bundler/gems/poke-api-fd27b2c9834f/lib/poke-api/client.rb:27:in rescue in login' from /Users/user/.rbenv/versions/2.0.0-p645/lib/ruby/gems/2.0.0/bundler/gems/poke-api-fd27b2c9834f/lib/poke-api/client.rb:23:inlogin'

Where does this stuff come from?

Hi there!

first of all thanks for your work.

I just have a simple question, I am currently stuck at understanding where the stuff from the fetch_endpoint method comes from:

get_player
get_hatched_eggs
get_inventory
check_awarded_badges
download_settings(hash: '4a2e9bc330dae60e7b74fc85b98868ab4700802e')

Where does it come from, what is it calling?

Thanks for any answer!

Niklas

Dropping inventory items

I'm trying to do an api call that drops items from the inventory, I've used get_inventory and then filtered the items that I want to drop, then I created a call like this

client.recycle_inventory_item(201, 10)
client.call

but then I get this error

Poke::API::Errors::UnknownProtoFault: An unknown proto fault has occured => [uninitialized constant RpcSub::RecycleInventoryItemRequest @ /[gem_path]/gems/poke-api-0.0.2/lib/poke-api/request_builder.rb:87:in `fetch_proto_request_class']

Is this because the RpcSub needs to map all requests, or am I doing something wrong?

An unknown proto fault has occured => [Expected number type for integral field. ... poke-api/request_builder.rb:90:in `initialize']

Hello again,

I have tried to integrate the "release_pokemon" RPC call. The output of inspect is the following:

#<Poke::API::Client @auth=#<Poke::API::Auth::GOOGLE:0x007fef17898088> @reqs=[{:RELEASE_POKEMON=>{:pokemon_id=>"1234567890"}}] @lat=0 @lng=0 @alt=0>

(I changed the pokemon_id)

The error is the following:

Poke::API::Errors::UnknownProtoFault (An unknown proto fault has occured => [Expected number type for integral field. @ /xxx/ruby-2.3.0/bundler/gems/poke-api-3223d8bf915b/lib/poke-api/request_builder.rb:90:in initialize']): app/controllers/pokemon_controller.rb:18:intransfer'

Line 18 is simply the call = client.call call.

I am not sure if I used the correct pokemon id, I guessed that this is the id I get from the regular get_inventory call. Is this correct or where do I get the pokemon id from?

Thanks for any help!

Locating pokestops

  lat = some_lat_here
  lng = some_lng_here

  client.store_lat_lng(lat, lng)

  cell_ids = Poke::API::Helpers.get_cells(lat, lng)

  client.get_map_objects(
    latitude: client.lat,
    longitude: client.lng,
    since_timestamp_ms: [0] * cell_ids.length,
    cell_id: cell_ids
  )

  resp = client.call
  puts resp.response[:GET_MAP_OBJECTS][:map_cells]

The following puts returns objects. In forts, I do see some results. But I dont see any indication of any pokestops. Does get_map_objects support this, at this time?

syntax error in gpsoauth

Hi! I have a problem running the program because of the syntax error in gpsoauth. I'm trying to log in with google account.
The error looks like below. Do you know how to fix this problem? Thanks in adv.

/Library/Ruby/Gems/2.0.0/gems/gpsoauth-rb-0.1.2/lib/gpsoauth.rb:26: syntax error, unexpected ':', expecting => (SyntaxError)
'accountType': 'HOSTED_OR_GOOGLE',
^
/Library/Ruby/Gems/2.0.0/gems/gpsoauth-rb-0.1.2/lib/gpsoauth.rb:26: syntax error, unexpected ',', expecting keyword_end
/Library/Ruby/Gems/2.0.0/gems/gpsoauth-rb-0.1.2/lib/gpsoauth.rb:27: syntax error, unexpected ':', expecting keyword_end
'Email': email,
^
/Library/Ruby/Gems/2.0.0/gems/gpsoauth-rb-0.1.2/lib/gpsoauth.rb:28: syntax error, unexpected ':', expecting :: or '[' or '.'
'has_permission': 1,
^

Issue with google login

I keep getting this issue when logging in with google:

INFO > Poke::API::Client --: [+] Logging in user: [email protected]
Poke::API::Errors::LoginFailure: Unable to login to GOOGLE => [undefined method split' for :"user-agent":Symbol @ /Users/xxx/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/net/http/header.rb:172:incapitalize']

To recreate:
client = Poke::API::Client.new
client.login("[email protected]","password","google")

Does not re-set api_url

Sometimes when a status is unsuccessful, it will return a code of 53 and a new api url. Can you add a method that checks for this and updates @endpoint accordingly. example response:

{:GET_PLAYER=>{:success=>false, :player_data=>nil}, :status_code=>53, :api_url=>"pgorelease.nianticlabs.com/plfe/327", :error=>""}

Adding proxy support to HTTPClient

Since Niantic is now blocking calls from major cloud services through IP detection - is there anyway we would implement the use of a proxy for HTTPClient ?

It could work this way:

client.store_proxy(url, user, pass)

And

def initialize(auth, pos, endpoint, proxy=nil, proxy_user=nil, proxy_password=nil)
  @access_token = auth.access_token
  @provider     = auth.provider
  @endpoint     = endpoint
  @position     = pos
  @client       = HTTPClient.new(proxy)
  @client.set_proxy_auth(user, password)
  @client.header["User-Agent"] = 'PokeAPI/0.0.1'
  @start_time   = (Time.now.to_f * 1000).to_i
end

https://github.com/nabeelamjad/poke-api/blob/master/lib/poke-api/request_builder.rb

Obtaining cell_ids

Hello, can you say how did you generated cell_id in the exmaple.rb ? And what cell_id we need?

gpsoauth is not compatible with ruby 2.0.0

I know that it's old as my grandma ass but that's my hosting platform and can't change it. Can we do something about it? Do I have to make a pull request in gpsoauth reverting compatibility? I don't want to use Google Login....

Revamp README into a proper Wiki

It's getting slightly out of hand, will need to (time permitting) use Github's wiki and provide a proper documentation on what can and can not be done in their own section without cluttering everything.

Is there any way to do sign in through Google Authentication rather than through the API?

Edit for Clarification:

is it possible to do authentication with Google rather than the API.
For example:

  1. Redirect a user to the google sign in page and retrieve an access token there
  2. Using that access token retrieve the endpoint for the API
  3. Continue to make requests as needed from there.

The purpose of this is to allow for a more secure login rather than inputting your username and password into the API.

EvolvePokemon is not working

I have the error

Poke::API::Errors::UnknownProtoFault - An unknown proto fault has occured => [uninitialized constant RpcSub::EvolvePokemonRequest

Not all protos files are required

I think you need to require all the Protos files.

It's impossible to retrieve the ID of a Pokemon for example (you get :RATTATA, and the POGOProtos.Enums.PokemonId is required to retrieve the pokedex index of the pokemon)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.