我正在尝试使用此存储库中的第三方 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))时,它工作得非常好。
谁能向我解释我做错了什么?