Code Monkey home page Code Monkey logo

snapchat's Introduction

Snapchat

STATUS

This library is not being actively maintained and AFAIK there is no easy way to get it working due to Snapchat updates and the Casper service no longer being public. If anyone is interested in adopting this project or knows a workaround to get this library working again, please feel free to reach out.

Nodejs client for the unofficial Snapchat API

This project is a node.js port of the excellent Objective-C SnapchatKit library by Tanner Bennett (ThePantsThief).

It provides an easy-to-use client interface to Snapchat's unofficial API, allowing Javascript developers to script Snapchat!

Install

npm install snapchat

Usage

The main entrypoint is the Snapchat class. See the auto-generated documentation for a detailed API reference.

Snapchat defaults to using required signin credentials stored in environment variables:

  • SNAPCHAT_USERNAME The Snapchat username to sign in with.
  • SNAPCHAT_PASSWORD The password to the Snapchat account to sign in with.
  • SNAPCHAT_GMAIL_EMAIL A valid GMail address.
  • SNAPCHAT_GMAIL_PASSWORD The password for the GMail address.
var Snapchat = require('snapchat')

var client = new Snapchat()
// note the signIn will default to credentials stored in environment variables
client.signIn(function (err, session) {
  if (!err) {
    console.log('signed in', client.username)
  }
})

Or with explicit credentials:

var Snapchat = require('snapchat')

var client = new Snapchat()
client.signIn('myusername', 'mypassword', '[email protected]', 'mygmailpassword', function (err, session) {
  if (!err) {
    console.log('signed in', client.username)
  }
})

NOTE Only Snapchat accounts created via an Android client should be used with this library. iOS accounts are handled separately by Snapchat, and your account will most likely be flagged / disabled as suspicious if you try to use a Snapchat account created on iOS.

NOTE Any valid gmail address and password may be used; it does not have to be the one the Snapchat user was created with.

Contribute

js-standard-style

See CONTRIBUTING.

Debugging

You can enable debug logs by setting the DEBUG environment variable:

DEBUG=snapchat,snapchat:*; # debug all snapchat submodules

Third party resources

Credits

  • Tanner Bennett (ThePantsThief), the auther of the Objective-C library SnapchatKit, which this version is heavily based on.
  • Everyone who built and maintains the PHP implementation.
  • See nykac's old node version.
  • Liam Cottle for his tenacious work on Casper and the API service he provides.

Author

Travis FischerGitHub/fisch0920Twitter/@fisch0920

Todo

  • MORE TESTS
  • rate limiting (currently test suite is failing with 401 errors because of rate limiting issues)
  • check logged status in Request.start response handler
  • handle request encoding properly for blobs and non-text requests
  • sendEvents inconsistent between Array[event] and event

License

MIT. Copyright (c) Travis Fischer.

Legal

I believe it's 100% legal to use a "private" REST API and that there are no laws explicitly prohibiting the use of "private" REST APIs. However, this does not mean that the makers of these private APIs can't try to sue you under something overly-broad, such as the CFAA. I don't think Snapchat will, personally; in my experience they've only gone after developers for copyright disputes.

Disclaimer: The name "Snapchat" is a copyright of Snapchat™, Inc. This project is in no way affiliated with, sponsored, or endorsed by Snapchat™, Inc. I, the project owner and creator, am not responsible for any legalities that may arise in the use of this project. Use at your own risk.

snapchat's People

Contributors

autarc avatar fduschka avatar marcbachmann avatar transitive-bullshit 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  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  avatar  avatar  avatar  avatar  avatar

snapchat's Issues

Can't login

I get the following error

{ message: 'Oh no! Your login temporarily failed, so please try again later. If your login continues to fail, please visit https://support.snapchat.com/a/failed-login :)',
status: -103,
logged: false }

TypeError: Cannot read property 'feature_settings' of undefined
at new Session (/Users/miketamis/Desktop/node_modules/snapchat/models/session.js:28:33)
at /Users/miketamis/Desktop/node_modules/snapchat/index.js:409:24
at Request.wrapcb as _callback
at Request.self.callback (/Users/miketamis/Desktop/node_modules/snapchat/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request. (/Users/miketamis/Desktop/node_modules/snapchat/node_modules/request/request.js:1073:14)
at Request.emit (events.js:117:20)
at IncomingMessage. (/Users/miketamis/Desktop/node_modules/snapchat/node_modules/request/request.js:1019:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:448:13)

I added console.log(params); to Session.js to get more info for ticket.

Can't login to snapchat using example

Code:
client.login('username', 'password').then(function(data) {
console.log(data);
}, function (err) {
console.log(err);
});
Console logs the err:
{ message: 'You're using a version of Snapchat or operating system that's no longer supported. Please upgrade your device's operating system and update to the newest app version to use Snapchat. Thanks!',
logged: false }

Can't mark snap as viewed

When I try to mark a snap as viewed with client.snaps.markSnapViewed(), it gives me the following error and stack trace:

TypeError: Cannot read property 'addedFriendsTimestamp' of undefined
    at Snaps.markSnapsViewed (./node_modules/snapchat/routes/snaps.js:121:70)
    at Snaps.markSnapViewed (./node_modules/snapchat/routes/snaps.js:92:15)
    ....

I have barely ever used Snapchat, but I can't see a reason why marking a snap as viewed would require any such timestamp. Is it supposed to be there?

Looking for someone to change my params.

Hello,

I just hooked an jailbroken device, and I extracted the Tokens.

However, I managed to use addfriend endpoint. and works perfectly.

But I tried to send a snap with failed attempt. sounds my image doesn't upload to snapchat servers for some reasons.

I need somebody to fix the params. Its a NodeJS script.

code: https://gist.github.com/mzaboss/9d4be77151eb7f366d6d69f0aacbb479

If you can help me am willing to pay good. Skype: mzaboss

Thank you,
regards.

Errors when trying to install package using npm

Shyamals-iMac-174:JillSteinApp shyamalchandra$ npm install snapchat

> [email protected] install /Users/shyamalchandra/JillSteinApp/node_modules/ursa
> node-gyp rebuild

  CXX(target) Release/obj.target/ursaNative/src/ursaNative.o
In file included from ../src/ursaNative.cc:3:
In file included from ../src/ursaNative.h:10:
../node_modules/nan/nan.h:324:27: error: redefinition of 'NanEnsureHandleOrPersistent'
  NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:319:17: note: previous definition is here
  v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                ^
../node_modules/nan/nan.h:344:27: error: redefinition of 'NanEnsureLocal'
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                          ^
../node_modules/nan/nan.h:334:27: note: previous definition is here
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:560:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:566:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback) {
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:571:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:577:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback) {
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:757:13: error: no member named 'smalloc' in namespace 'node'
    , node::smalloc::FreeCallback callback
      ~~~~~~^
../node_modules/nan/nan.h:768:12: error: no matching function for call to 'New'
    return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
           ^~~~~~~~~~~~~~~~~
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/node_buffer.h:46:40: note: candidate function not viable: 2nd
      argument ('const char *') would lose const qualifier
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/node_buffer.h:34:40: note: candidate function not viable: no known
      conversion from 'const char *' to 'v8::Local<v8::String>' for 2nd argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/node_buffer.h:31:40: note: candidate function not viable: requires 2
      arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/node_buffer.h:39:40: note: candidate function not viable: requires 5
      arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../src/ursaNative.cc:3:
In file included from ../src/ursaNative.h:10:
../node_modules/nan/nan.h:772:12: error: no viable conversion from returned value of type 'v8::MaybeLocal<v8::Object>'
      to function return type 'v8::Local<v8::Object>'
    return node::Buffer::New(v8::Isolate::GetCurrent(), size);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:218:7: note: candidate constructor
      (the implicit copy constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>' to
      'const v8::Local<v8::Object> &' for 1st argument
class Local {
      ^
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:218:7: note: candidate constructor
      (the implicit move constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>' to
      'v8::Local<v8::Object> &&' for 1st argument
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:222:13: note: candidate template ignored: could not match
      'Local' against 'MaybeLocal'
  V8_INLINE Local(Local<S> that)
            ^
In file included from ../src/ursaNative.cc:3:
In file included from ../src/ursaNative.h:10:
../node_modules/nan/nan.h:779:26: error: no member named 'Use' in namespace 'node::Buffer'
    return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
           ~~~~~~~~~~~~~~^
In file included from ../src/ursaNative.cc:3:
In file included from ../src/ursaNative.h:9:
In file included from /Users/shyamalchandra/.node-gyp/6.5.0/include/node/node.h:42:
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:229:5: error: assigning to 'v8::Primitive *volatile' from
      incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:188:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:501:12: note: in instantiation of function template specialization
      'v8::Local<v8::Primitive>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/ursaNative.cc:3:
In file included from ../src/ursaNative.h:9:
In file included from /Users/shyamalchandra/.node-gyp/6.5.0/include/node/node.h:42:
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:229:5: error: assigning to 'v8::Boolean *volatile' from
      incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:188:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:511:12: note: in instantiation of function template specialization
      'v8::Local<v8::Boolean>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/ursaNative.cc:3:
In file included from ../src/ursaNative.h:9:
In file included from /Users/shyamalchandra/.node-gyp/6.5.0/include/node/node.h:42:
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:229:5: error: assigning to 'v8::Function *volatile' from
      incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:188:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1645:12: note: in instantiation of function template specialization
      'v8::Local<v8::Function>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/ursaNative.cc:3:
In file included from ../src/ursaNative.h:9:
In file included from /Users/shyamalchandra/.node-gyp/6.5.0/include/node/node.h:42:
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:229:5: error: assigning to 'v8::Object *volatile' from
      incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/shyamalchandra/.node-gyp/6.5.0/include/node/v8.h:188:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1776:12: note: in instantiation of function template specialization
      'v8::Local<v8::Object>::Local<v8::Value>' requested here
    return NanEscapeScope(
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
14 errors generated.
make: *** [Release/obj.target/ursaNative/src/ursaNative.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/shyamalchandra/JillSteinApp/node_modules/ursa
gyp ERR! node -v v6.5.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
[email protected] /Users/shyamalchandra/JillSteinApp
└── (empty)

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "snapchat"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ursa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ursa
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ursa
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/shyamalchandra/JillSteinApp/npm-debug.log
npm ERR! code 1

What am I doing wrong or is the package invalid now?

Upgrading Casper API breaks login

After switching to the new API endpoints I can't login anymore (previous still works). Seems like the Snapchat authorization fails with the generated credentials.

.

.

GoogleAuthToken

I used the example with my own credentials. I get an Snapchat._getGoogleAuthToken error 827:21 from the node_module during login.

The login account is created on an Android device!

Library broken (DroidGuard service down)

I was messing around with the Snapchat app and this library a bit to see why #27 the Google Auth token couldn't be retrieved. I see multiple calls made to https://android.clients.google.com/auth, but in all the requests the app header is com.google.android.gms and the parameter for the callerPkg is com.google.android.gms too. I see no requests made to the auth endpoint with the Snapchat package name during login, logout and general usage of the app so from this I assume that the Snapchat app is not making any calls to the auth endpoint.

So I tried editing the library to work without the need of a Google Auth token (as it seems the Snapchat android app can work without requesting it). I then ran into another issue. The login request takes a parameter called attestation, and this library retrieves that value through the Casper API. But the problem is these endpoints are no longer active.

Both of these endpoints return not found:
https://api.casper.io/droidguard/create/binary
https://api.casper.io/droidguard/attest/binary

{
    "code": 404,
    "message": "The DroidGuard Service is no longer available."
}

I'm not sure how the Snapchat android app generates the attestation value, this will require decompiling the app which I've not looked into.

I've not looked any further than this. It does seem possible to reissue the login request hours later and it works fine. So it may be possible to reuse the attestation value after manually receiving it once?

Cant login

Hello when i try this

var Snap = require('snapchat');
  // var config = require('config.json')('./config.json');

var client = new Snap();
client.signIn('deliemoilekes', 'MYPASS', '[email protected]', 'MYPASS', function (err, session) {
  if (!err) {
    console.log('signed in', client.username);
  } else {
    console.log(err);
  }
});

i get this error

[root@localhost Snapchat]# DEBUG=snapchat,snapchat:* node index.js
  snapchat new snapchat client +0ms
  snapchat Snapchat.signIn (username deliemoilekes) +3ms
  snapchat error getting attestation +612ms
Snapchat._getAttestation unknown error

TypeError

buffer.js:257
  throw new TypeError(kFromErrorMsg);

I get this error when I start my script?!

Use the public Casper API

Since the API defined at https://api.casper.io/ got public endpoints for the security calls which supports SSL/HTTPS in contrast the former service, it could be usefull to switch. Unfortunately even after updating the digest to the latest version (9.14.2) the generated signature doesn't seem to match.

Doesn't work with Node 6

de-gyp"
make: Entering directory '/home/rocco/Desktop/PROVE/prove-snapchat/node_modules/ursa/build'
  CXX(target) Release/obj.target/ursaNative/src/ursaNative.o
In file included from ../src/ursaNative.h:10:0,
                 from ../src/ursaNative.cc:3:
../node_modules/nan/nan.h:324:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureHandleOrPersistent(const v8::Local<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                           ^
../node_modules/nan/nan.h:319:17: note: ‘template<class T> v8::Handle<T> Nan::imp::NanEnsureHandleOrPersistent(v8::Handle<T>&)’ previously declared here
   v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                 ^
../node_modules/nan/nan.h:344:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(v8::Handle<T>&)’

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.