-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_twitter.php
43 lines (35 loc) · 1.12 KB
/
demo_twitter.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
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Demo_twitter extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper(array('url'));
$this->load->library(array('oauthclient'));
$this->oauthclient->setOauthDataStore("user_oauth");
$this->oauthclient->setService("twitter");
$this->oauthclient->setConsumerKey("twitter-consumer-key-goes-here");
$this->oauthclient->setConsumerSecret("twitter-consumer-secret-goes-here");
$this->oauthclient->setResponseUrl("http://your-domain/demo_twitter/response/");
}
function index()
{
redirect('/demo_twitter/connect/');
}
function connect() {
$this->oauthclient->connect();
}
function response() {
$userId = $this->oauthclient->response();
print "<p>User ID ".$userId." is logged in.</p>";
print "<a href=\"/demo_twitter/profile/".$userId."\">View user profile.</a>";
}
function profile($userId = 1) {
$this->oauthclient->setUserId($userId);
$xmlProfile = $this->oauthclient->getProfile();
print "<h1>User profile</h1>";
print "<pre>";
print_r($xmlProfile);
print "</pre>";
}
}