1

このリポジトリからサードパーティの SnapChat API を使用しようとしています。

これが私が実行しているPHPコードです。

<?php

/* TODO - Debug show errors */
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Start or continue the session
session_start();
// Require the php-snapchat-master api
require_once("../api/snapchat.php");
// If the user is logged in
if (isset($_SESSION["username"]) && isset($_SESSION["password"])) {
  // Redirect to the home page
  header("Location: ../home/");
}
// If the username and password are not set
else {
  // Break PHP to show HTML
  ?>
  <form method="POST">
    <input type="username" name="username" placeholder="Username" />
    <input type="password" name="password" placeholder="Password" />
    <input type="submit" value="Log In" />
  </form>
  <?php // End PHP break
  // If the log in form was submitted
  if (isset($_POST["username"]) && isset($_POST["password"])) {
    // Initialize the prospective user
    $snapchat = new Snapchat();
    // If the username and password are not valid
    if ($snapchat->login($_POST["username"], $_POST["password"]) == FALSE) {
      // ECHO INVALID
      echo "INVALID";
    }
    // If the username and password are valid
    else {
      // ECHO VALID
      echo "VALID";
      // Set the username session variable
      $_SESSION["username"] = $_POST["username"];
      // Set the password session variable
      $_SESSION["password"] = $_POST["password"];
      // Redirect to the home page
      header("Location: ../home/");
    }
  }
}
?>

残念ながら、SnapChat の正しいユーザー名とパスワードを入力するたびに、ページにデバッグINVALIDステートメントが表示されます。ログインに常に真のチェック(if(TRUE == TRUE)など)を追加すると、なぜこれが起こるのかわかりませんが、完全に正常に機能します。

誰かが私が間違っていることを説明できますか?

4

1 に答える 1

2

Snapchat のログイン方法が変更されました :/ そのため、この API は更新が必要です。コードは気にしないでください。大丈夫です ;)

編集:見つかりました!

この「API」で使用されるユーザー エージェントを変更する必要があります: snapchat_agent.php に移動し、次のように $CURL_OPTIONS を変更します。

public static $CURL_OPTIONS = array(
    CURLOPT_CONNECTTIMEOUT => 5,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_USERAGENT => 'Snapchat/8.1.1 (Nexus 5; Android 21; gzip)',
    CURLOPT_HTTPHEADER => array('Accept-Language: en'),
);
于 2014-12-25T02:57:26.947 に答える