JorgenPhi / php-snapchat

A PHP library for the Snapchat API - With Commit History
MIT License
260 stars 73 forks source link

SnapChat API "register" #19

Open MartinMeijer1980 opened 10 years ago

MartinMeijer1980 commented 10 years ago

Hello i am trying to add a new snapchat user through the API

I have made my self a form with:

I'm sending the form and requesting the next code $SC = new Snapchat; getHtml::getTagP($SC->register($_POST['gebruiker'], $_POST['wachtwoord'], $_POST['email'], $_POST['geboortedatum']));

I have puted random in that function an echo with text and found out that it stops at the next line of code (rule 190) if (!isset($result->token)) { return FALSE; }

Now is my next question...

Sorry for my questions, but i couldn't find much information regarding this

Kind regards, Martin Meijer

JorgenPhi commented 10 years ago

This current version does not have capacha solving built in, which is what I believe is the problem. Try looking at one of the forks, maybe someone has figured it out. :) On May 1, 2014 8:25 AM, "MartinMeijer1980" notifications@github.com wrote:

Hello i am trying to add a new snapchat user through the API

I have made my self a form with:

  • Username
  • Password
  • Birthdate
  • Email

I'm sending the form and requesting the next code $SC = new Snapchat; getHtml::getTagP($SC->register($_POST['gebruiker'], $_POST['wachtwoord'], $_POST['email'], $_POST['geboortedatum']));

I have puted random in that function an echo with text and found out that it stops at the next line of code (rule 190) if (!isset($result->token)) { return FALSE; }

Now is my next question...

  • what do i need to configure in this script? (to let it work with the domain of my customer)
  • How can u really add a new user?

Sorry for my questions, but i couldn't find much information regarding this

Kind regards, Martin Meijer

— Reply to this email directly or view it on GitHubhttps://github.com/JorgenPhi/php-snapchat/issues/19 .

MartinMeijer1980 commented 10 years ago

Euhm... how do you mean this? The request can't past the captcha controller of snapchat...

So if i'm right... i can skip this one and look to it later?

And the uri in the file "snapchat_agent.php" on line 25

Its pointing to "URL = 'https://feelinsonice-hrd.appspot.com/bq';" do i need to keep it like that or do i need to make an own link?

PS: Tanks for your fast reply

Kind regards, Martin Meijer

dprogramming commented 10 years ago

You have to keep that URL

MartinMeijer1980 commented 10 years ago

Thank you

This is helping me out on this way!

dprogramming commented 10 years ago

You're welcome. What do you mean with this: "Euhm... how do you mean this? The request can't past the captcha controller of snapchat...

So if i'm right... i can skip this one and look to it later?"?

MartinMeijer1980 commented 10 years ago

Well i can't register a new user for snapchat with this API, its returning nothing

Jorgen told that "This current version does not have capacha solving built in" (i believe he is meaning captcha)

So i'm looking for a way to work around this so i can make new accounts at Snapchat with the api

Sorry that i'm not alway's clear (just a dutchman overhere :P)

dprogramming commented 10 years ago

No problem :P I'm from Belgium so... :) Yes, he's meaning captcha, that's not included in this project, you'll have to look for it in another fork or project or create your own implementation. I'm looking for it too, so if you have found a way around, let me know ;)

MartinMeijer1980 commented 10 years ago

Ok, thanks!

Than i will first go on with the other functions

If i'm ready with that i will look again to solve the register with captcha working

I will post it overhere

Kind regards, Martin Meijer

dprogramming commented 10 years ago

Great! If you have a question, just post/ask it!

Follow me on Twitter - @LenaertsDaan

JorgenPhi commented 10 years ago

Sorry for not being clearer and for the typo. I am commenting on my phone in class. Let us know if you have any more questions! On May 1, 2014 8:46 AM, "dprogramming" notifications@github.com wrote:

Great! If you have a question, just post/ask it!

Follow me on Twitter - @LenaertsDaan

— Reply to this email directly or view it on GitHubhttps://github.com/JorgenPhi/php-snapchat/issues/19#issuecomment-41910927 .

MartinMeijer1980 commented 10 years ago

Does someone gets this, it looks like they are explaining how to get a work around

http://www.hakobaito.co.uk/b/bypassing-snaptcha

Can someone verrifie this for me?

Again thanks

dprogramming commented 10 years ago

Hello, this looks a solution to me, I did not test it but I think it's a working solution. It's written by Hako, he has a fork of this repository so... - https://github.com/hako/php-snapchat/ - I don't have time to test it right now but if you do, please post your results here...

Thanks

MartinMeijer1980 commented 10 years ago

I'm busy with it now, and have seen that it's still not verry easy

In first he needs now a header.txt

There are only a few new classes in the fork of Hako

This is the code that i'm testing now

    $SC     = new Snapchat();
    $SC->register($_POST['gebruiker'], $_POST['wachtwoord'], $_POST['email'], $_POST['geboortedatum']); 

    $captcha_id = $SC->getCaptcha($_POST['email']);
    // Im not getting an Captcha id... maybe its because the user isn't registering
    echo "captcha? - ".$captcha_id;

    // This is a strange one, i dont get this. I also have an error on this one
    // Warning: fgets() expects parameter 1 to be resource, string given in 
    $solution = fgets(STDIN); // Solution is in binary.

    $SC->sendCaptcha($username, $captcha_id, $solution);

I will keep on testing, but if someone has some time to also look into it, i would appriciate that!

So i have my script like they are telling me on this site (http://www.hakobaito.co.uk/b/bypassing-snaptcha)

But i'm not even getting the first post /bg/register like that... so thats my first problem. Could there be an other reason that i'm not getting the information back like they are telling

Thanks again for your time

Kind regards, Martin Meijer

MartinMeijer1980 commented 10 years ago

Ok its working, i have triggerd some errors in snapchat_agent.php on line 260 is $result = curl_exec($ch);

This contains important information why there something wrong with the post, the password needs to be 8 chars at least and for the rest it works fine :)

Maybe an errorhandler wouldn't be difficult to make...

I now need to work on an other project, i will go further later this day with this script.

Thanks again and if you have questions let me know

Kind regards Martin Meijer

dprogramming commented 10 years ago

Great, I would want to help you but unfortunately I'm still busy :/ keep us updated..

Thanks

hako commented 10 years ago

@MartinMeijer1980 Did you get it working? I've been kind of busy with some uni work thus unable to update the php-snapchat fork.

Also the captcha_id is only obtained through the dumped headers.txt. (For some reason snapchat sends 401 UNAUTHORIZED if you request the headers.)

MartinMeijer1980 commented 10 years ago

@hako i had deleted my snapchat account, i got all the request on the proper way

So after i have registerd my self (i'm not getting an email or sms text so i know it went good). But i have logged in at snapchat site with the emailadress and given password and it worked like a charm

i can't login with the given username only with the given email

so it is possible to register, only the error handling is not given a nice message back, so i need to make that one for my self. And maybe i'm going to make in my script a mail with the information about snapchat

If you have any questions let me know

Kind regards, Martin

dprogramming commented 10 years ago

Hello again, did you get it working? If so it would be very helpful if you would post your final code here.

Thanks

MartinMeijer1980 commented 10 years ago

@dpprogramming it's partial working... i have also downloaded the new fork of Hako

Now i can register a user but....

After i register my self a new account, i only can login on the website of Snapchat but not at the SnapChat app on my Android phone

At the first time it wasn't possible to use the given username (not the email) to login i got a message that the account didn't exists.

Now with the new update in the fork of Hako it's possible to use the username, i can login the website of snapchat. But if i whant to login into snapchat on my android phone it sais "Invalid Account"

I have the feeling that i need to send a SMS to the snapchat phonenumber? At least i can find something like that to do?

Can someone help me to pass this one?

Im going to make a class thats also handeling errors

MartinMeijer1980 commented 10 years ago

I have a code what's the return messages of register_username

Array ( [birthday] => 1980-07-18 [number_of_best_friends] => 3 [logged] => 1 [story_privacy] => FRIENDS [username] => martin1980nl1 [can_see_custom_stories] => 1 [name] => martin1980nl1 [display] => Team Snapchat [snap_p] => 1 [mobile_verification_key] => MjE3NzptYXJ0aW4xOTgwbmwx [0] => martin1980nl1 [notification_sound_setting] => OFF [snapchat_phone_number] => +31636465228 [auth_token] => 2713bddd-204b-480a-ad31-354a4a646c33 [current_timestamp] => 1399452793953 [email] => meijer.mw@kpnmail.nl [title] => Content Warning [message] => The red exclamation mark on this Story indicates that Stories posted by this user may not be suitable for sensitive viewers. Do you wish to continue? After selecting 'Yes', you will never be prompted again. [yes_text] => Yes [no_text] => No [1] => teamsnapchat [last_interaction_ts] => 1399447288635 [sn] => teamsnapchat [t] => 10 [timer] => 10 [id] => 175103399447288211r [st] => 1 [ts] => 1399447288211 [sts] => 1399447288211 [payload] => eyJ1c2VybmFtZSI6Im1hcnRpbjE5ODBubDEiLCJ0aW1lc3RhbXAiOjEzOTk0NTI3OTM4OTR9 [mac] => D2B9GG_oHT4IfbgT6IdfqxXG09cXH1tWVNOAWhMxUVQ= [type] => needs_captcha [text] => Welcome to chat! 👻 [chat_message_id] => 1799b615-82f9-4229-953d-4eff87ddcd04 [seq_num] => 1 [timestamp] => 1399447288632 [from] => teamsnapchat [conv_id] => martin1980nl1~teamsnapchat [iter_token] => {"teamsnapchat":2} [teamsnapchat] => 4 [last_writer] => teamsnapchat [last_write_timestamp] => 1399447288635 [last_write_type] => text [gateway_server] => 108.59.85.17:443 [background_fetch_secret_key] => PqiXToE2RPJ+SKLpho1LALnvaOYh82rgd6IgekRRErs= [prompt] => Select all images containing a ghost. )

MartinMeijer1980 commented 10 years ago

Now i see that there is standing an old phonenumber of my in the results...

How does they become to my number? It's in this case not a good one!

Kind regards

MartinMeijer1980 commented 10 years ago

Even when i use a new emailaddress the request is still getting an old phonenumber of mine... how the * is this possible... i can't find annything whats pointing to that number... verry strange

Some ideas?

dprogramming commented 10 years ago

That's very strange, maybe it helps if you clear your cache, but I doubt. Do you only use a different email address? Or are there other things the same? Can't you still not sign in on the official updated Android app?

MartinMeijer1980 commented 10 years ago

Hello,

If you read my posts right... while registering to snapchat with the fork of Hako it's filling in my old phonenumber

My first question is where does he get that phonenumber from? Because it's an old one

I assume when it's registerd an account with an old phonenumber that it's impossible to login to snapchat at my phone with an other phonenumber

I also asume you need to get a text message to activate the account and to verrifie the phonenumber

I need some more information about these steps

dprogramming commented 10 years ago

Normally it should be possible to sign in with another account in the Android app. But I don't think you should get a text message on your phone, at least in the previous versions. Maybe that's changed now, I don't know for sure. Have you tried removing and reinstalling the Snapchat app on your phone? But in your code you never mention your phone number? And while registering it is getting your old phone number?

JorgenPhi commented 10 years ago

Your account type is [type] => needs_captcha which is why you cannot login with it.

Hello,

If you read my posts right... while registering to snapchat with the fork of Hako it's filling in my old phonenumber

My first question is where does he get that phonenumber from? Because it's an old one

I assume when it's registerd an account with an old phonenumber that it's impossible to login to snapchat at my phone with an other phonenumber

I also asume you need to get a text message to activate the account and to verrifie the phonenumber

I need some more information about these steps

— Reply to this email directly or view it on GitHubhttps://github.com/JorgenPhi/php-snapchat/issues/19#issuecomment-42417237 .

dprogramming commented 10 years ago

Ooh you didn't solve the captcha? @MartinMeijer1980

MartinMeijer1980 commented 10 years ago

@JorgenPhi

I thought it was a working fork...

How do i need to solve this? Is there only a problem with registering accounts?

The strange is i have made an account, because i can login with the emailaddress of the new account into http://snapchat.com i assume tha account has been made OK. Only thing thats not correspending is my phonenumber in the array that i'm getting back.

So if there is a documentation of SnapChat them self i would appriciate that, maybee i can figure more things out.

@dpprogramming Thats true there is standing a verry old phonenumber of mine (JorgenPhi could have been right... but still i want first the phonenumber ok otherwise i cant test this issue)

Kind regards

dprogramming commented 10 years ago

Snapchat doesn't have a documentation, they even don't have an official public API. You'll have to use the captcha to be able to create an account. They don't use captchas that long. Maybe they didn't change their online sign in system to be working without the captcha registration.?

JorgenPhi commented 10 years ago

The other fork has a method to solve captchas, but does not solve it automatically. You still need to download the captcha image, read it, and then push the solution. On May 7, 2014 7:50 AM, "dprogramming" notifications@github.com wrote:

Snapchat doesn't have a documentation, they even don't have an official public API. You'll have to use the captcha to be able to create an account. They don't use captchas that long. Maybe they didn't change their online sign in system to be working without the captcha registration.?

— Reply to this email directly or view it on GitHubhttps://github.com/JorgenPhi/php-snapchat/issues/19#issuecomment-42422407 .

dprogramming commented 10 years ago

Of course you still have to solve them manually! It's not a captcha hack... Is just an implementation of signing up. Didn't you use the captcha anywhere in your signup?

MartinMeijer1980 commented 10 years ago

Yes i used it, but its not downloading the image

I have a headers.txt the script is not even doing annything with it (at first i had an error on it, thats why i made the headers.txt)

And the code thats getting a binary solutions is given an error thats why i put the @ in front of it

$solution = @fgets(STDIN);

Dont get that rule...

Ok clear if that needs to go on that way... strange about the API has no documentation... how in the world is it possible that you guy's can make things like this?

Thanks again

MartinMeijer1980 commented 10 years ago

Ok im getting the headerinfo first i didnt got this

"* About to connect() to feelinsonice-hrd.appspot.com port 443 (#0)

dprogramming commented 10 years ago

Maybe @hako can help you with the captcha script? He created it. This API is reversed engineered from the official IOS/Android app, based on the official code this is a PHP implementation, but unfortunately there's no documentation...

MartinMeijer1980 commented 10 years ago

I only need to get the captcha code than i can make the rest around it

But the strange is, i'm doing it like there is standing @hako his fork

dprogramming commented 10 years ago

Are you doing it like this? ''' <?php

include 'src/snapchat.php';

// dummy variables.

$email = "spevanegiel@gmail.com"; $password = "snapchat1001"; $birthday = "1963-05-04"; $username = "spevenspatula01";

$s = new Snapchat();

// register normally..

$s->register($email,$password,$birthday);

// register your desired username..

$s->register_username($email, $username);

// verify yourself...

$captcha_id = $s->getCaptcha($username, true);

// ask the user for the captcha, // (should be replaced with respected ghost images)... // // returns false if unable to retrive captcha_id.

var_dump($captcha_id);

echo "captcha?";

$solution = fgets(STDIN); // solution is 8 characters in binary. eg. 001010011

// send off captcha.

$s->sendCaptcha($solution, $captcha_id, $username);

?>

'''

MartinMeijer1980 commented 10 years ago

yes

dprogramming commented 10 years ago

I'm not sure but maybe this have to be done differently with the updated captcha system. Maybe @hako has a working example? I would be willing to help you with testing but I'm already too busy... :(

MartinMeijer1980 commented 10 years ago

No there is so far no working one i found

dprogramming commented 10 years ago

Maybe I'll be able to help testing this code on Friday... Hopefully hako has a working example, but not on the github page..,

hako commented 10 years ago

The endpoint for the solve_captcha is /bq/solve_captcha not ph/solve_captcha I'll see to it later

dprogramming commented 10 years ago

Okay, great.

MartinMeijer1980 commented 10 years ago

Ah nice i will test this in a few hours, thank you

MartinMeijer1980 commented 10 years ago

@hako i have edited the request from /solve_cpatcha i have edit it with bq/ in front of it

Still no download

The $captcha_id is also false... so there must be an other solution to work around this

MartinMeijer1980 commented 10 years ago

I cant connect to this link, if this is not going to work than it's impossible to add an account (thats my feeling)

hako commented 10 years ago

What do you mean no download? Do you mean the .zip captcha file?

MartinMeijer1980 commented 10 years ago

Or i have the wrong data given through (that is causing the 400 Bad Request and why i dont get the download)

First i must solve the Captcha it keeps givin false in stead of username~digits

The second problem is with the header.txt that i'm having a 400 bad request

hako commented 10 years ago

I tested my fork on ubuntu and was able to download the captcha zip, what OS are you using?

dprogramming commented 10 years ago

I'm getting false too, when using your example on your github fork. I tested on Windows using Xampp server. @hako

hako commented 10 years ago

Not sure if it could be SSL or not, try adding this line:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

To the snapchat_agent.php file in the post method.