How mgp25/sc-api works
Project type and purpose
• This is a PHP client‐library (Composer package “mgp25/snapapi”) that wraps the Snapchat/Casper API for other PHP apps or scripts. It is not a full web app or microservice fleet, but a reusable API wrapper with built-in crypto, caching, and example clients.
File structure
• Top‐level:
• composer.json, README.md, LICENSE – package metadata
• examples/ – standalone PHP scripts that consume the library
• src/ – library code and assets:
• src/Casper-API-PHP/ – core API wrapper classes (CasperAPI, CasperAgent, exceptions)
• src/phpseclib/ – 3rd‐party crypto modules (AES, RSA, Hash, BigInteger, etc.)
• src/snapchat*.php – high‐level Snapchat‐specific facades
• src/func.php – utility functions
• src/authData/, src/cache/ – local filesystem storage for tokens, session data
• src/fonts/, src/ca_bundle.crt – assets for HTTPS and story rendering
• src/snaps/, src/stories/, src/Discover/ – placeholder folders for downloaded media
README
• Confirms Composer installation, need for Casper API key/secret, shows example usage.
• Points to Casper.io service as the external backend.
a. Main components
– CLIENT SCRIPTS (examples/*.php)
– SNAPAPI LIBRARY
· Entry point: CasperAPI
· HTTP/crypto layer: CasperAgent + phpseclib modules
· Facade: snapchat.php / snapchat_agent.php / snapchat_cache.php
· Utils: func.php
· Local storage: authData, cache, fonts, ca_bundle.crt
– EXTERNAL SERVICE: Casper API (HTTPS endpoints)
b. Relationships & data flow
1. Developer script → instantiates CasperAPI with credentials
2. CasperAPI calls CasperAgent to build/encrypt HTTP request (uses phpseclib)
3. CasperAgent → sends HTTPS request → Casper API service
4. Response → CasperAgent decrypts/parses → CasperAPI returns data
5. CasperAPI writes session tokens/media to local folders (authData, cache, snaps, stories)
c. Architectural patterns
– Facade/wrapper over low‐level HTTP + crypto operations
– Layered: API classes → Transport/crypto layer → Storage layer
– Dependency isolation: phpseclib vendored under src/phpseclib
d. Key technologies & libraries
– PHP 7+ with Composer
– phpseclib for encryption (AES, RSA, etc.)
– Casper API over HTTPS
– Filesystem storage for caching and media
Be detailed but focused
• Every directory that plays a runtime role (phpseclib, authData, cache, fonts)
• Two main layers (API facade vs. transport/crypto)
• Local filesystem as a first‐class “component”