/**
  * Fetches all Headers and Parameters required to make a Snapchat API request to the Endpoint provided.
  * Additional Endpoints may be returned at the same time.
  *
  * @param string $username
  *   Your Snapchat Username
  *
  * @param string $auth_token
  *   Your Snapchat AuthToken
  *
  * @param string $endpoint
  *   Snapchat API Endpoint
  *
  * @return object
  *   Response Object
  *
  * @throws CasperException
  *   An exception is thrown if an error occurs.
  */
 public function getSnapchatIOSEndpointAuth($username, $auth_token, $endpoint)
 {
     $response = parent::post("/snapchat/ios/endpointauth", null, array("username" => $username, "auth_token" => $auth_token, "endpoint" => $endpoint));
     if (!isset($response->endpoints)) {
         throw new CasperException("Endpoints Object not found in Response");
     }
     return $response;
 }
Esempio n. 2
0
 /**
  * Fetches an Attestation by making multiple API calls to the Google and Casper APIs.
  *
  * @param string $nonce
  *   Base64 encoded value of the nonce
  *   sha256(username|password|timestamp|/loq/login)
  *
  * @return string
  *   The Client Auth Token
  *
  * @throws CasperException
  *   An exception is thrown if an error occurs.
  */
 public function getSnapchatAttestation($nonce)
 {
     $response = parent::get("/snapchat/attestation/create");
     if (!isset($response->binary)) {
         throw new CasperException("Binary not found in Response");
     }
     $binary = base64_decode($response->binary);
     $response = parent::externalRequest("https://www.googleapis.com/androidantiabuse/v1/x/create?alt=PROTO&key=AIzaSyBofcZsgLSS7BOnBjZPEkk4rYwzOIz-lTI", array("Content-Type: application/x-protobuf", "User-Agent: SafetyNet/7899000 (klte KOT49H); gzip"), $binary, true);
     $protobuf = base64_encode($response);
     $response = parent::post("/snapchat/attestation/attest", null, array("protobuf" => $protobuf, "nonce" => $nonce, "snapchat_version" => self::SNAPCHAT_VERSION));
     if (!isset($response->binary)) {
         throw new CasperException("Binary not found in Response");
     }
     $binary = base64_decode($response->binary);
     $response = parent::externalRequest("https://www.googleapis.com/androidcheck/v1/attestations/attest?alt=JSON&key=AIzaSyDqVnJBjE5ymo--oBJt3On7HQx9xNm1RHA", array("Content-Type: application/x-protobuf", "User-Agent: SafetyNet/7899000 (klte KOT49H); gzip"), $binary, true);
     $json = json_decode($response);
     if ($json == null) {
         throw new CasperException("Failed to decode response!");
     }
     if (!isset($json->signedAttestation)) {
         throw new CasperException("Attestation not found in Response");
     }
     return $json->signedAttestation;
 }