Exemple #1
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;
 }