My favorites | Sign in
Project Logo
                
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
session_start();

require_once 'OAuth/Consumer.php';

$options = array(
'requestScheme' => OAuth::REQUEST_SCHEME_HEADER,
'version' => '1.0', // there is only a 1.0 version for now ;)
'signatureMethod' => 'HMAC-SHA1',
'localUrl' => 'http://path/to/this/file.php', // change to this file's local URL
'requestTokenUrl' => 'http://ma.gnolia.com/oauth/get_request_token',
'userAuthorisationUrl' => 'http://ma.gnolia.com/oauth/authorize',
'accessTokenUrl' => 'http://ma.gnolia.com/oauth/get_access_token',
);

// replace with your own real application consumer key and key secret!
$consumer = new OAuth_Consumer('CONSUMER_KEY', 'CONSUMER_KEY_SECRET', $options);

if (!isset($_SESSION['ACCESS_TOKEN'])) {
if (!empty($_GET)) {
$token = $consumer->getAccessToken($_GET, unserialize($_SESSION['REQUEST_TOKEN']));
$_SESSION['ACCESS_TOKEN'] = serialize($token);
} else {
$token = $consumer->getRequestToken();
$_SESSION['REQUEST_TOKEN'] = serialize($token);
$consumer->redirect();
exit;
}
} else {
$token = unserialize($_SESSION['ACCESS_TOKEN']);
$_SESSION['ACCESS_TOKEN'] = null;
}

$methodUrl = 'http://ma.gnolia.com/api/rest/2/bookmarks_count';
$rawData = $token->toQueryString($methodUrl, $consumer, array('group'=>'oauth'));
$client = new HTTP_Request;
$client->setURL($methodUrl);
$client->setMethod(HTTP_REQUEST_METHOD_POST);
$client->setRawPostData($rawData);

$client->sendRequest();
header('Content-Type: ' . $client->getResponseHeader('Content-Type'));
echo $client->getResponseBody();
Show details Hide details

Change log

r33 by padraic.brady on Jun 28, 2008   Diff
RSA signing implemented internally, and a
Magnolia example update
Go to: 
Project members, sign in to write a code review

Older revisions

r19 by padraic....@yahoo.com on Jun 23, 2008   Diff
Ma.gnolia Example
All revisions of this file

File info

Size: 1586 bytes, 43 lines
Hosted by Google Code