Skip to content

Instantly share code, notes, and snippets.

@flashwave
Last active November 9, 2018 13:09
Show Gist options
  • Save flashwave/7649d389de7d71fa112c to your computer and use it in GitHub Desktop.
Save flashwave/7649d389de7d71fa112c to your computer and use it in GitHub Desktop.
http://flash.moe/apitest.php - Flashii Profile API Testing
<?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>';
@wokark10
Copy link

wokark10 commented Dec 9, 2014

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

@flashwave
Copy link
Author

That'll be a thing soon, like tekuno said it's one step forward towards a full api.

@flashwave
Copy link
Author

groupStyle is deprecated

@flashwave
Copy link
Author

Added a thing that checks if the API/Server is down or doesn't return anything.

@flashwave
Copy link
Author

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