-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from citelao/feature-plugin
dev: web api scaffolding
- Loading branch information
Showing
83 changed files
with
13,155 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
// thanks to http:https://www.alfredforum.com/topic/1788-prevent-flash-of-no-result | ||
mb_internal_encoding("UTF-8"); | ||
date_default_timezone_set('America/New_York'); | ||
|
||
use OhAlfred\OhAlfred; | ||
require 'vendor/autoload.php'; | ||
|
||
$alfred = new OhAlfred(); | ||
$session = new SpotifyWebAPI\Session($alfred->options('spotify_client_id'), $alfred->options('spotify_secret'), 'http:https://localhost:11114/callback.php'); | ||
|
||
// Request a access token using the code from Spotify | ||
$session->requestToken($_GET['code']); | ||
|
||
// Save the tokens | ||
$alfred->options("spotify_access_token", $session->getAccessToken()); | ||
$alfred->options("spotify_refresh_token", $session->getRefreshToken()); | ||
$alfred->options("spotify_access_token_expires", time() + $session->getExpires()); | ||
|
||
?> | ||
<html> | ||
<head> | ||
<title>Spotifious Setup</title> | ||
|
||
<link rel="stylesheet" href="include/setup/style/normalize.css" /> | ||
<link rel="stylesheet" href="include/setup/style/style.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="wrapper" class="wrapper"> | ||
<section> | ||
<h1>Spotifious should be setup :)</h1> | ||
<p> | ||
You should be able to start using Spotifious now! | ||
</p> | ||
|
||
<p>(enjoy)</p> | ||
</section> | ||
</div> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
// thanks to http:https://www.alfredforum.com/topic/1788-prevent-flash-of-no-result | ||
mb_internal_encoding("UTF-8"); | ||
date_default_timezone_set('America/New_York'); | ||
|
||
use OhAlfred\OhAlfred; | ||
require '../../vendor/autoload.php'; | ||
|
||
$response = Array(); | ||
|
||
if(!$_GET["id"] || !$_GET["secret"]) { | ||
// If we opt out, display the opt out page | ||
if ($_GET["opt_out"]) { | ||
?> | ||
<html> | ||
<head> | ||
<title>Spotifious Setup</title> | ||
|
||
<link rel="stylesheet" href="style/normalize.css" /> | ||
<link rel="stylesheet" href="style/style.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="wrapper" class="wrapper"> | ||
<section> | ||
<h1>Setup complete!</h1> | ||
<p>You've successfully opted out of using a Spotify app.</p> | ||
<p> | ||
You can always opt back in using the settings menu in | ||
Spotifious. Just type <kbd>s</kbd> in Spotifious. | ||
</p> | ||
<p>You can now reopen Spotifious to continue setup.</p> | ||
</section> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
<?php | ||
exit(); | ||
} | ||
|
||
// If we didn't opt out, we're missing information. | ||
$response["status"] = "error"; | ||
$response["message"] = "You're missing some data!"; | ||
echo json_encode($response); | ||
exit(); | ||
} | ||
|
||
$alfred = new OhAlfred(); | ||
|
||
// Test connection | ||
$session = new SpotifyWebAPI\Session($_GET["id"], $_GET["secret"], 'http:https://localhost:11114/callback.php'); | ||
|
||
$scopes = array( | ||
'playlist-read-private', | ||
'user-read-private' | ||
); | ||
|
||
try { | ||
$session->requestCredentialsToken($scopes); | ||
} catch(SpotifyWebAPI\SpotifyWebAPIException $e) { | ||
$response["status"] = "error"; | ||
|
||
$response["message"] = "Invalid data - "; | ||
if ($e->getMessage() == "Invalid client") { | ||
$response["message"] .= "invalid ID"; | ||
} elseif($e->getMessage() == "Invalid client secret") { | ||
$response["message"] .= "incorrect secret"; | ||
} else { | ||
$response["message"] .= $e->getMessage(); | ||
} | ||
|
||
echo json_encode($response); | ||
exit(); | ||
} | ||
|
||
// Save data | ||
$alfred->options('spotify_client_id', $_GET["id"]); | ||
$alfred->options('spotify_secret', $_GET["secret"]); | ||
$alfred->options('spotify_access_token', ''); | ||
$alfred->options('spotify_access_token_expires', ''); | ||
$alfred->options('spotify_refresh_token', ''); | ||
|
||
$response["status"] = "success"; | ||
$response["message"] = "Saved your information! Make sure to do step 8 :)"; | ||
echo json_encode($response); | ||
exit(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.