| author | Raphael Velt <raph.velt@gmail.com> |
| Fri, 23 Mar 2012 15:06:16 +0100 | |
| changeset 563 | 0dd745105665 |
| parent 557 | 636258d3fe4b |
| child 844 | c086c7ab3f38 |
| permissions | -rwxr-xr-x |
|
0
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
1 |
<?php |
|
563
0dd745105665
Tests for IE9 cookie issues
Raphael Velt <raph.velt@gmail.com>
parents:
557
diff
changeset
|
2 |
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); |
|
0
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
3 |
/** |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
4 |
* include some common code (like we did in the 90s) |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
5 |
* People still do this? ;) |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
6 |
*/ |
|
233
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
7 |
include_once 'common.php'; |
|
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
8 |
if(!isset($_REQUEST['rep'])) { |
|
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
9 |
$rep = $C_default_rep; |
|
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
10 |
} |
|
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
11 |
else { |
|
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
12 |
$rep = $_REQUEST['rep']; |
|
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
13 |
} |
|
10d6fd6ce9ab
- put all in a registry
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
229
diff
changeset
|
14 |
|
|
0
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
15 |
|
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
16 |
/** |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
17 |
* Someone's knocking at the door using the Callback URL - if they have |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
18 |
* some GET data, it might mean that someone's just approved OAuth access |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
19 |
* to their account, so we better exchange our current Request Token |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
20 |
* for a newly authorised Access Token. There is an outstanding Request Token |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
21 |
* to exchange, right? |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
22 |
*/ |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
23 |
if (!empty($_GET) && isset($_SESSION['TWITTER_REQUEST_TOKEN'])) { |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
24 |
$token = $consumer->getAccessToken($_GET, unserialize($_SESSION['TWITTER_REQUEST_TOKEN'])); |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
25 |
$_SESSION['TWITTER_ACCESS_TOKEN'] = serialize($token); |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
26 |
|
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
27 |
/** |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
28 |
* Now that we have an Access Token, we can discard the Request Token |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
29 |
*/ |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
30 |
$_SESSION['TWITTER_REQUEST_TOKEN'] = null; |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
31 |
|
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
32 |
/** |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
33 |
* With Access Token in hand, let's try accessing the client again |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
34 |
*/ |
|
557
636258d3fe4b
Allow iframe authentication
Raphael Velt <raph.velt@gmail.com>
parents:
233
diff
changeset
|
35 |
header('Location: ' . ( isset($_SESSION['TWITTER_REDIRECT_URL']) ? $_SESSION['TWITTER_REDIRECT_URL'] : ( URL_ROOT . "$rep/client.php" ) ) ); |
|
0
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
36 |
} else { |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
37 |
/** |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
38 |
* Mistaken request? Some malfeasant trying something? |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
39 |
*/ |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
40 |
exit('Invalid callback request. Oops. Sorry.'); |
|
4eba9c11703f
first import
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
41 |
} |