Commit 98eaf0d2 authored by Jonas Haraldsson's avatar Jonas Haraldsson

user-connections.php: connect to remote gnufm

$gnufm_key need to be set in nixtape/config.php for it to show up
parent 8b344312
......@@ -38,8 +38,14 @@
{if isset($lastfm_key)}
<a href='http://www.last.fm/api/auth/?api_key={$lastfm_key}'>{t}Connect to a Last.fm account{/t}</a><br /><br />
{/if}
{if isset($gnufm_key)}
<form method="post">
<h4>Connect to a remote GNU FM account</h4>
<input name="remote_gnufm_url" type="text" placeholder="http://mygnufmserver.tld" />
<button type="submit">Connect</button>
</form>
{/if}
</center>
</div>
{include file='footer.tpl'}
......@@ -32,6 +32,14 @@ if ($logged_in == false) {
die();
}
if (isset($_POST['remote_gnufm_url'])) {
// redirect to a foreign GNU FM service
$remote_url = $_POST['remote_gnufm_url'];
$callback_url = $base_url . '/user-connections.php?webservice_url=' . $remote_url . '/2.0/';
$url = $remote_url . '/api/auth/?api_key=' . $gnufm_key . '&cb=' . rawurlencode($callback_url);
header('Location: ' . $url);
}
if (isset($_GET['token']) && isset($_GET['webservice_url'])) {
// Handle authentication callback from a foreign service
$token = $_GET['token'];
......@@ -88,6 +96,9 @@ if (isset($_GET['forward']) && isset($_GET['service'])) {
if (isset($lastfm_key)) {
$smarty->assign('lastfm_key', $lastfm_key);
}
if (isset($gnufm_key)) {
$smarty->assign('gnufm_key', $gnufm_key);
}
$smarty->assign('connections', $this_user->getConnections());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment