This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-08-23 17:58:45

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Authenticating Scratch username/password with PHP?

Title.

I'm working on a site that authenticates using Scratch.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#2 2012-08-23 18:08:33

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

You can use the Scratch API for this!  smile

Code:

scratch.mit.edu/api/authenticateuser?username=INSERTUSERNAMEHERE&password=INSERTPASSWORDHERE

Offline

 

#3 2012-08-24 08:55:48

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

ProgrammingFreak wrote:

You can use the Scratch API for this!  smile

Code:

scratch.mit.edu/api/authenticateuser?username=INSERTUSERNAMEHERE&password=INSERTPASSWORDHERE

How do I use that in my PHP code?


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#4 2012-08-24 09:30:09

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

Code:

<?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:

Code:

<?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.


/* No comment */

Offline

 

#5 2012-08-24 09:46:36

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

Yeah, TS. It works:

Code:

<?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

 

#6 2012-08-24 12:14:34

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

You may want to wrap the POST strings with rawurlencode(), though.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#7 2012-08-24 21:46:36

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

Wow, thanks all! Adding to my site now...


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#8 2012-08-24 22:03:49

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

If anybody wants to see it, it's here.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#9 2012-08-24 22:13:20

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

technoboy10 wrote:

If anybody wants to see it, it's here.

Nice!

This is the code used on Mod Share, btw.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#10 2012-08-25 10:14:31

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

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.)


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#11 2012-08-25 10:16:00

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

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.  tongue 
Because I'm guessing that Mod Share used the code for the same reason you did. Because it was already provided by Scratch.  tongue

Nice clean urls. ;3

Last edited by ProgrammingFreak (2012-08-25 10:16:25)

Offline

 

#12 2012-08-25 23:19:49

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

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.  tongue 
Because I'm guessing that Mod Share used the code for the same reason you did. Because it was already provided by Scratch.  tongue

Nice clean urls. ;3

Ok, cool.

And thanks. :3


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#13 2012-08-26 00:14:09

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

Didn't I already give you the code?  tongue


Hai.

Offline

 

#14 2012-08-26 09:28:05

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

fg123 wrote:

Didn't I already give you the code?  tongue

It didn't actually work for me, so I'm trying some simpler approaches.  smile


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#15 2012-10-24 15:01:03

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Authenticating Scratch username/password with PHP?

I might use this too, it seems to work well :3


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#16 2012-10-24 16:54:03

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

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.


I am currently http://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=imagehttp://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=text and I finally got over 1000 posts.

Offline

 

#17 2012-10-24 21:26:36

pwiter
Scratcher
Registered: 2010-06-02
Posts: 100+

Re: Authenticating Scratch username/password with PHP?

It's not that great because the password aren't encrypted.


http://i.imgur.com/YBeXc.png

Offline

 

#18 2012-10-25 13:13:51

ahirbhairav
Scratcher
Registered: 2012-10-06
Posts: 100+

Re: Authenticating Scratch username/password with PHP?

technoboy10 wrote:

If anybody wants to see it, it's url=http://www.scratchgalaxy.tk/login here

Broken link? Not working, unaccesible...

Offline

 

#19 2012-10-25 14:43:13

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Authenticating Scratch username/password with PHP?

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.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#20 2012-10-25 15:03:31

ahirbhairav
Scratcher
Registered: 2012-10-06
Posts: 100+

Re: Authenticating Scratch username/password with PHP?

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

 

Board footer