我試圖從this存儲庫使用第三方SnapChat API。PHP SnapChat Master - 正確登錄憑據返回無效登錄
這是我正在運行的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)),那麼它工作得很好。
任何人都可以向我解釋我做錯了什麼?
我也不會感到驚訝,如果在Snapchat的人改變了自己的API又一次爲流氓客戶辯護,即使這在技術上是不可能的,他們應該接受;如果是緊急情況,你可以自己MITM的應用程序,並修復圖書館;否則就等着別人去做吧。 –