PHP Classes

Discogs Patch

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Discogs Patch  >  (Un) Subscribe thread alerts  
Subject:Discogs Patch
Summary:Adding support for discos with this patch
Messages:2
Author:Heiko Wichmann
Date:2014-02-08 13:52:23
Update:2014-03-17 10:32:36
 

  1. Discogs Patch   Reply   Report abuse  
Picture of Heiko Wichmann Heiko Wichmann - 2014-02-08 13:52:23
Hello Manuel,

please add support for Discogs with this patch.


Thanks a lot!

Best,

Heiko


case 'Discogs':
$this->oauth_version = '1.0a';
$this->request_token_url = 'http://api.discogs.com/oauth/request_token';
$this->dialog_url = 'http://www.discogs.com/oauth/authorize';
$this->access_token_url = 'http://api.discogs.com/oauth/access_token';
break;



<?php
/*
* login_with_discogs.php
*
*/

/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require('http.php');
require('oauth_client.php');

$client = new oauth_client_class;
$client->server = 'Discogs';

$client->debug = true;
$client->debug_http = true;
$client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].
dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/login_with_discogs.php';

$client->client_id = ''; $application_line = __LINE__;
$client->client_secret = '';

if(strlen($client->client_id) == 0
|| strlen($client->client_secret) == 0)
die('Please go to Discogs API developer page '.
'https://www.discogs.com/settings/developers, '.
'create an applicartion client ID, and in the line '.$application_line.
' set the client_id to Consumer Key and client_secret to Consumer Secret. '.
'The callback URL must be '.$client->redirect_uri);

/* API permissions
*/
$client->scope = 'read,write';
if(($success = $client->Initialize()))
{
if(($success = $client->Process()))
{
if(strlen($client->access_token))
{
$success = $client->CallAPI(
'http://api.discogs.com/oauth/identity',
'GET', array(), array('FailOnAccessError'=>true), $user);
}
}
$success = $client->Finalize($success);
}
if($client->exit)
exit;
if($success)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Discogs OAuth client results</title>
</head>
<body>
<?php
echo '<h1>', HtmlSpecialChars($user->username),
' you have logged in successfully with Discogs!</h1>';
echo '<pre>', HtmlSpecialChars(print_r($user, 1)), '</pre>';
?>
</body>
</html>
<?php
}
else
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>OAuth client error</title>
</head>
<body>
<h1>OAuth client error</h1>
<pre>Error: <?php echo HtmlSpecialChars($client->error); ?></pre>
</body>
</html>
<?php
}

?>

  2. Re: Discogs Patch   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-03-17 10:32:36 - In reply to message 1 from Heiko Wichmann
Discogs support was integrated in the latest release. Thank you for the support.