2014-12-24 114 views
1

我試圖從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)),那麼它工作得很好。

任何人都可以向我解釋我做錯了什麼?

+0

我也不會感到驚訝,如果在Snapchat的人改變了自己的API又一次爲流氓客戶辯護,即使這在技術上是不可能的,他們應該接受;如果是緊急情況,你可以自己MITM的應用程序,並修復圖書館;否則就等着別人去做吧。 –

回答

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'), 
); 
+0

謝謝!這很有效 –

+0

發現更新後,'Snapchat/8.1.1'^需要更改爲'Snapchat/9.0.1' –