Snap API Documentation

mgp25 edited this page Oct 10, 2015 · 11 revisions

Getting Started

Get Casper API token

This will be required in order to make this API works.

Go to https://clients.casper.io/login.php and create an account. Once you have created an account go to "Projects" and create a new project.

projects

Now you will have your project with your API Key and API Secret.

api

You will need to set this data in the constructor.

Account registration

Use registerTool.php https://github.com/mgp25/Snap-API/blob/master/examples/registerTool.php

Note: This is a CLI tool, not for webservers.

It will ask you for the account data:

Username: SnapTest

Password: thisIsMyPassword

Email: snaptest@myemail.com

Birthday (yyyy-mm-dd): 1970-01-01

You should have a file called 'SnapTest1427058809780.zip' in your snap api folder, unzip it. You will have 9 images (image0.png, image1.png ...).

I have my 9 images:

captcha

Image with ghost = 1 Image without ghost = 0

So my result is: 111000000

Result: 111000000

REQUEST TO: https://feelinsonice-hrd.appspot.com/bq/solve_captcha

Sent Request info: POST /bq/solve_captcha HTTP/1.1
User-Agent: Snapchat/9.2.0.0 (A0001; Android 4.4.4#5229c4ef56#19; gzip)
Host: feelinsonice-hrd.appspot.com
Accept: */*
Accept-Language: en;q=1
Accept-Locale: en
Content-Length: 185
Content-Type: application/x-www-form-urlencoded


DATA: username=SnapTest&timestamp=1427058852343&captcha_id=SnapTest%7E1427058809780&captcha_solution=111000000&req_token=b134a4f8e7f0cc00bd922dc4e08e4b25a7caffb3ff9d985a42d3317a7b260615
RESULT:

Account successfully created

Username: SnapTest
Password: thisIsMyPassword
Email: snaptest@myemail.com

If there is any error while registering your account, it will appear this:

There was an error registering your account
Error code: 401

Error 401: UNAUTHORIZED

Error 403: FORBIDDEN

Logging in

$username = ""; // Your snapchat username
$password = ""; // Your snapchat password
$gEmail   = ""; // Gmail account
$gPasswd  = ""; // Gmail account password
$debug = false; // Set this to true if you want to see all outgoing requests and responses from server

$snapchat = new Snapchat($username, $gEmail, $gPasswd, $debug);

//Login to Snapchat with your username and password
$snapchat->login($password);

Sending Snaps

$imagePath = ""; // URL or local path to a media file (image or video)
$sendTo = array(); // Single or multiple recipients

// Send snap adding text to your image and 10 seconds
$snapchat->send($imagePath, $sendTo, "this is a test :D", 10);

Sending a message

$message = 'Hello from Snap-API';
$to = 'username';

$snapchat->sendMessage($to, $msg);

Setting a story

Remember that videos must be less or equal 10 seconds duration.

$imagePath = ""; // URL or local path to a media file (image or video)
$snapchat->setStory($imagePath);

You can also set a text to the image story.

$snapchat->setStory($imagePath, $time, $text);

Getting your friend list

$friends = $snapchat->getFriends();

Getting Snaps

// Get snaps data
$snapchat->getSnaps();

// Automatically downloads Snaps and store it in 'snaps' folder
$snapchat->getSnaps(true);

Getting Friends Stories

// Get stories data
$snapchat->getFriendStories();

// Automatically downloads Snaps and store it in 'stories' folder
$snapchat->getFriendStories(true);

Adding / Deleting a friend

$snapchat->addFriend($username);
$snapchat->deleteFriend($username);

Find friends

$friends = array(
    "Snap API" => "123456789"
);
$snapchat->findFriends($friends);

Events / Analytics

Open App

When you have the auth-<username>.dat you can call openAppEvent()

$snapchat->openAppEvent();

Close App

If you are not logging out, you should send close app event:

$snapchat->closeAppEvent();

Other settings

Setting a proxy

You can set an http proxy by doing this:

$myProxy = "http://myproxy.com:8080";
$snapchat->setProxyServer($myProxy);
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.