Last active
November 9, 2018 13:09
-
-
Save flashwave/7649d389de7d71fa112c to your computer and use it in GitHub Desktop.
http://flash.moe/apitest.php - Flashii Profile API Testing
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
<?php | |
// Check if "uid" GET request is set | |
if(isset($_GET['uid'])) { | |
// Get data from remote server and surpress errors | |
$apiData = @file_get_contents('http://flashii.net/u/' . $_GET['uid'] . '/api'); | |
// If nothing was retrieved display the following error and die | |
if($apiData == FALSE) { | |
die('<h1>Failed to retrieve API data!</h1>Is Flashii.net down?'); | |
} | |
// Decode the returned JSON | |
$userData = json_decode($apiData, true); | |
// If the "error" key is set to true return Invalid user! | |
if($userData['error']) { | |
print '<h1>Invalid user!</h1>'; | |
} else { // Otherwise display most of the stuff the API can return. | |
print '<h1>' . $userData['userName'] . '</h1>'; | |
print '<pre>'; | |
print 'ID: ' . $userData['userID'] . '<br />'; | |
print 'Title: ' . $userData['userTitle'] . '<br />'; | |
print 'Group ID: ' . $userData['groupID'] . '<br />'; | |
print 'Group Title: ' . $userData['groupName'] . '<br />'; | |
print 'Group Colour: ' . $userData['groupColour'] . '<br />'; | |
print 'Joined Timestamp: ' . $userData['joinTimeStamp'] . '<br />'; | |
print 'Last Active Timestamp: ' . $userData['lastTimeStamp'] . '<br />'; | |
print 'Markdown Base 64: ' . $userData['markdown'] . '<br />'; | |
print 'Avatar: <img src="' . $userData['userAvatar'] . '" /><br />'; | |
print 'Background: <img src="' . $userData['userBackground'] . '" /><br />'; | |
print '</pre>'; | |
} | |
} else { // If the "uid" GET request isn't set return a form to make the user set it | |
print '<h1>No UserID set!</h1>'; | |
print '<form method="get">'; | |
print '<input type="text" name="uid" />'; | |
print '<input type="submit" />'; | |
print '</form>'; | |
} | |
// Print a link to this GIST | |
print '<br /><a href="https://gist.github.com/flashwave/7649d389de7d71fa112c" target="_blank">Source</a>'; |
That'll be a thing soon, like tekuno said it's one step forward towards a full api.
groupStyle is deprecated
Added a thing that checks if the API/Server is down or doesn't return anything.
This API is now deprecated because of the introduction of a proper API in Sakura
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would be nice to have an authentication mechanism.
E.g. site123.net would like to verify UserY has an account on flashii.net
http://api.flashii.net/authenticate?user=UserY&pass=UserYpassword is called from site123.net
if successful, user_valid: true is returned along with the data from http://flashii.net/u/[uid]/api