forked from erikeldridge/openid_oauth_hybrid_app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
proxy.php
39 lines (32 loc) · 1.11 KB
/
proxy.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
<?php
/**
* This is a proxy script for making 3-leg requests using php sdk.
* Currently, it is hardcoded to request the profile info only.
*/
require_once 'config.inc.php';
require_once '../yosdk/OAuth.php';
$consumer = new OAuthConsumer(YAHOO_OAUTH_APP_KEY, YAHOO_OAUTH_APP_SECRET);
//extract request token from storage
$accessToken = json_decode(file_get_contents('accessToken.txt'));
//prep request for access token
$url = 'http://query.yahooapis.com/v1/yql';
$params = array('q'=>'select * from social.profile where guid=me');
$request = OAuthRequest::from_consumer_and_token($consumer, $accessToken, 'GET', $url, $params);
$request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, $accessToken);
$headers = array(
"Accept: application/json"
);
//make request
$ch = curl_init($request->to_url());
$options = array(
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
curl_close($ch);
//error-tip: if request is rejected, refresh access token and re-request
//output
header('Content-type: application/json');
echo $response;
?>