Title.
I'm working on a site that authenticates using Scratch.
Offline
You can use the Scratch API for this!
scratch.mit.edu/api/authenticateuser?username=INSERTUSERNAMEHERE&password=INSERTPASSWORDHERE
Offline
ProgrammingFreak wrote:
You can use the Scratch API for this!
Code:
scratch.mit.edu/api/authenticateuser?username=INSERTUSERNAMEHERE&password=INSERTPASSWORDHERE
How do I use that in my PHP code?
Offline
<?php $response = trim(file_get_contents('http://scratch.mit.edu/api/authenticateuser?username=' . $_POST['username'] . '&password=' . $_POST['password'])); if($response == 'false'){ //failed auth } else { //$response contains UserID:Username:BlockedStatus } ?>
To test if a user is blocked:
<?php $parts = explode(':', $response); if($parts[2] == 'unblocked'){ //Not blocked } else { //Blocked } ?>
Not tested, so I don't know how much (if any) of it will work.
Offline
Yeah, TS. It works:
<?php $response = trim(file_get_contents('http://scratch.mit.edu/api/authenticateuser?username=' . $_GET['username'] . '&password=' . $_GET['password'])); if($response == 'false'){ echo "fail"; } else { $parts = explode(':', $response); if ($parts[2] == "unblocked"){echo "confirmed";} } ?>
Offline
Wow, thanks all! Adding to my site now...
Offline
If anybody wants to see it, it's here.
Offline
jvvg wrote:
technoboy10 wrote:
If anybody wants to see it, it's here.
Nice!
This is the code used on Mod Share, btw.
Okay, should I give credit? (I might release the code of this site under a Creative Commons license, FYI.)
Offline
technoboy10 wrote:
jvvg wrote:
technoboy10 wrote:
If anybody wants to see it, it's here.
Nice!
This is the code used on Mod Share, btw.Okay, should I give credit? (I might release the code of this site under a Creative Commons license, FYI.)
No, you don't need to.
Because I'm guessing that Mod Share used the code for the same reason you did. Because it was already provided by Scratch.
Nice clean urls. ;3
Last edited by ProgrammingFreak (2012-08-25 10:16:25)
Offline
ProgrammingFreak wrote:
technoboy10 wrote:
jvvg wrote:
Nice!
This is the code used on Mod Share, btw.Okay, should I give credit? (I might release the code of this site under a Creative Commons license, FYI.)
No, you don't need to.
Because I'm guessing that Mod Share used the code for the same reason you did. Because it was already provided by Scratch.
Nice clean urls. ;3
Ok, cool.
And thanks. :3
Offline
fg123 wrote:
Didn't I already give you the code?
It didn't actually work for me, so I'm trying some simpler approaches.
Offline
I used to use this when I owned Go Everywhere, and I hope that the guy who owns it now will continue it. The less usernames and passwords the user has to remember, the better.
Offline
technoboy10 wrote:
If anybody wants to see it, it's url=http://www.scratchgalaxy.tk/login here
Broken link? Not working, unaccesible...
Offline
ahirbhairav wrote:
technoboy10 wrote:
If anybody wants to see it, it's url=http://www.scratchgalaxy.tk/login here
Broken link? Not working, unaccesible...
Hmm... I might have deleted it. Check the /source directory just to make sure.
Offline
Checked that's not available. Apparently, the last time it was seen was on the 10th of October, the same day the new season of NOVA premiered.
Offline