File: digg_a_story.php

package info (click to toggle)
php-oauth 2.0.2%2B1.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 816 kB
  • ctags: 950
  • sloc: ansic: 7,197; xml: 841; php: 536; makefile: 1
file content (32 lines) | stat: -rw-r--r-- 1,167 bytes parent folder | download | duplicates (10)
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
<?php

include('config.inc.php');

try {
$oauth = new OAuth(DIGG_CONSUMER_KEY, DIGG_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_FORM);
$request_token = $oauth->getRequestToken("http://services.digg.com/1.0/endpoint?method=oauth.getRequestToken");

echo "Go to http://digg.com/oauth/authorize?oauth_token={$request_token["oauth_token"]} and enter the code (PIN) given at the end of the flow @ digg\n";
$in = fopen("php://stdin", "r");
$verifier = fgets($in, 255);

echo "Grabbing an access token...\n";

$oauth->setToken($request_token["oauth_token"], $request_token["oauth_token_secret"]);
$access_token = $oauth->getAccessToken("http://services.digg.com/1.0/endpoint?method=oauth.getAccessToken", NULL, $verifier);

echo "Got an access token: " . $access_token["oauth_token"];

$oauth->setToken($access_token["oauth_token"], $access_token["oauth_token_secret"]);

$oauth->fetch("http://services.digg.com/1.0/endpoint?method=story.digg", array("story_id" => "21595036"));

$xml = simplexml_load_string($oauth->getLastResponse());

echo "http://digg.com/programming/PHP_OAuth_Manual has been dugg\n";

} catch (OAuthException $E) {
var_dump($E);
}

?>