/
index.php
51 lines (43 loc) · 1.03 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
# simple REST approach
if($_SERVER["REQUEST_METHOD"] == "GET")
{
include "templates/index.html.php";
}
else if ($_SERVER["REQUEST_METHOD"] == "POST" && !isset($_POST['_method']))
{
if( !empty($_POST["username"]) && !empty($_POST["password"]) )
{
require_once "lib/twittonio.php";
# sanitize the post parameters
$username = htmlspecialchars($_POST["username"]);
$password = htmlspecialchars($_POST["password"]);
#initialize the twitter object
$twit = new Twittonio($username, $password);
# try to login
if( $twit->verifyCredentials() )
{
# get the list of the followers' screen names
$followers = $twit->getFollowersScreenNames();
# get the list of the friends' screen names
$friends = $twit->getFriendsScreenNames();
}
else
{
$flash_message = "Wrong credentials!";
}
}
else
{
$flash_message = "Please enter a username and password!";
}
if(isset($followers) && isset($friends))
{
include "templates/list.html.php";
}
else
{
include "templates/index.html.php";
}
}
?>