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

#1 2011-04-30 14:13:06

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

scratch.mit.edu/api

I need to know some things about this.
Is there a page to get the most recent project of a user, or the __th recent/oldest project?

Offline

 

#2 2011-04-30 14:20:03

PythonLibrary
Scratcher
Registered: 2011-03-26
Posts: 100+

Re: scratch.mit.edu/api

There is no scratch.mit.edu/api (The link)


http://dl.dropbox.com/u/9137793/Python%20Library%20logo.png
Our website: pylibrary.co.cc http://dl.dropbox.com/u/9137793/Awesomeness%20Block.gif

Offline

 

#3 2011-04-30 14:27:23

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: scratch.mit.edu/api

PythonLibrary wrote:

There is no scratch.mit.edu/api (The link)

I know that.
But look at http://scratch.mit.edu/api/getproject/1588557

Offline

 

#4 2011-04-30 14:41:51

PythonLibrary
Scratcher
Registered: 2011-03-26
Posts: 100+

Re: scratch.mit.edu/api

scimonster wrote:

PythonLibrary wrote:

There is no scratch.mit.edu/api (The link)

I know that.
But look at http://scratch.mit.edu/api/getproject/1588557

So here is how you did it (?) 1. You took those numbers in your project URL. 2. you changed the /users/scimonster to api/getproject/*numbers*. Is this how you did it?


http://dl.dropbox.com/u/9137793/Python%20Library%20logo.png
Our website: pylibrary.co.cc http://dl.dropbox.com/u/9137793/Awesomeness%20Block.gif

Offline

 

#5 2011-04-30 14:46:06

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: scratch.mit.edu/api

PythonLibrary wrote:

scimonster wrote:

PythonLibrary wrote:

There is no scratch.mit.edu/api (The link)

I know that.
But look at http://scratch.mit.edu/api/getproject/1588557

So here is how you did it (?) 1. You took those numbers in your project URL. 2. you changed the /users/scimonster to api/getproject/*numbers*. Is this how you did it?

That is the Scratch api part of the site.

Offline

 

#6 2011-04-30 14:53:09

gettysburg11
Scratcher
Registered: 2008-06-14
Posts: 1000+

Re: scratch.mit.edu/api

scimonster wrote:

Is there a page to get the most recent project of a user, or the __th recent/oldest project?

I've wondered if there was a way to do this. It looks like if you type a project number at the end of the /api url, it'll bring up that numbered project. That's something I'll have to remember.


http://i256.photobucket.com/albums/hh184/mnacmilan/LOGO_ACMILAN-Splash.gif

Offline

 

#7 2011-04-30 19:07:33

ihaveamac
Scratcher
Registered: 2007-09-22
Posts: 1000+

Re: scratch.mit.edu/api

I like the getproject API. I found the 1337th projectbig_smile


~ihaveamac - visit ihaveamac.net

Offline

 

#8 2011-04-30 19:34:07

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: scratch.mit.edu/api

ihaveamac wrote:

I like the getproject API. I found the 1337th projectbig_smile

And the 1,000,000th project!  big_smile


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#9 2011-05-01 00:41:34

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: scratch.mit.edu/api

Please, stop playing around here. I'm looking for an answer. Scratch Team maybe?

Offline

 

#10 2011-05-01 00:47:14

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: scratch.mit.edu/api

scimonster wrote:

Please, stop playing around here. I'm looking for an answer. Scratch Team maybe?

The API isn't officially supported by the Scratch Team -_- I think...

I was going to use this to detect the latest user for my windows 7 gadget -_-


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#11 2011-05-01 01:35:12

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: scratch.mit.edu/api

ssss wrote:

scimonster wrote:

Please, stop playing around here. I'm looking for an answer. Scratch Team maybe?

The API isn't officially supported by the Scratch Team -_- I think...

I was going to use this to detect the latest user for my windows 7 gadget -_-

if it wasn't, then how would it be there?


Posts: 20000 - Show all posts

Offline

 

#12 2011-05-01 04:53:55

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: scratch.mit.edu/api

veggieman001 wrote:

ssss wrote:

scimonster wrote:

Please, stop playing around here. I'm looking for an answer. Scratch Team maybe?

The API isn't officially supported by the Scratch Team -_- I think...

I was going to use this to detect the latest user for my windows 7 gadget -_-

if it wasn't, then how would it be there?

Paddle2see wrote:

Hey ssss,

The API apparently doesn't have official documentation yet...and it's not really supported by the Scratch Team at this point either.  But if you want to take a look at the source code, it is here

http://trac.assembla.com/scratchr/brows … roller.php

You also might want to talk to ask in the Advanced Topics area to see who has experience using it (maybe JSO?) to see if they can give you any pointers.  Good luck!


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#13 2011-05-01 04:59:36

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: scratch.mit.edu/api

ssss wrote:

veggieman001 wrote:

ssss wrote:


The API isn't officially supported by the Scratch Team -_- I think...

I was going to use this to detect the latest user for my windows 7 gadget -_-

if it wasn't, then how would it be there?

Paddle2see wrote:

Hey ssss,

The API apparently doesn't have official documentation yet...and it's not really supported by the Scratch Team at this point either.  But if you want to take a look at the source code, it is here

http://trac.assembla.com/scratchr/brows … roller.php

You also might want to talk to ask in the Advanced Topics area to see who has experience using it (maybe JSO?) to see if they can give you any pointers.  Good luck!

What's the link to?

Offline

 

#14 2011-05-01 06:07:44

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: scratch.mit.edu/api

scimonster wrote:

ssss wrote:

veggieman001 wrote:


if it wasn't, then how would it be there?

Paddle2see wrote:

Hey ssss,

The API apparently doesn't have official documentation yet...and it's not really supported by the Scratch Team at this point either.  But if you want to take a look at the source code, it is here

http://trac.assembla.com/scratchr/brows … roller.php

You also might want to talk to ask in the Advanced Topics area to see who has experience using it (maybe JSO?) to see if they can give you any pointers.  Good luck!

What's the link to?

?

That should link to API code


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#15 2011-05-01 06:24:06

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: scratch.mit.edu/api

ssss wrote:

scimonster wrote:

ssss wrote:

veggieman001 wrote:

if it wasn't, then how would it be there?

What's the link to?

?

That should link to API code

It's not valid.

Offline

 

#16 2011-05-01 06:55:14

wulfmaster
Scratcher
Registered: 2011-04-23
Posts: 500+

Re: scratch.mit.edu/api

scimonster wrote:

ssss wrote:

scimonster wrote:


What's the link to?

?

That should link to API code

It's not valid.

Go find the post


Social Connections - Bringing communities close together! http://cyberkidscountry.com/ip.php

Offline

 

#17 2011-05-01 10:10:28

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: scratch.mit.edu/api

scimonster wrote:

ssss wrote:

scimonster wrote:

What's the link to?

?

That should link to API code

It's not valid.

Scratch abbreviates the URL when you use the URL tag, so that's not the complete link. Let me see if I can find the original link.

Edit: Found it.

Last edited by Harakou (2011-05-01 10:12:46)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#18 2011-05-01 10:21:34

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: scratch.mit.edu/api

Harakou wrote:

scimonster wrote:

ssss wrote:


?

That should link to API code

It's not valid.

Scratch abbreviates the URL when you use the URL tag, so that's not the complete link. Let me see if I can find the original link.

Edit: Found it.

Thank you!  big_smile

Offline

 

#19 2011-06-29 13:14:01

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: scratch.mit.edu/api

I needed my site to check the validity of a Scratch username and password and thought that people might like the php code.

Code:

$t1 = trim(file_get_contents('http://scratch.mit.edu/api/authenticateuser?username=' . $_POST['scratchUsername'] . '&password=' . $_POST['scratchPassword']));
            if($t1 == 'false'){
                echo "The username or password you entered was incorrect!";
            }
            else{
                echo "Username and password correct!";
            }
        }

Your POST names may of course differ and the echo message can be changed to anything but this works very neatly!

file_get_contents() is a php command I found that pulls the contents of an entire file into a variable string for your use.

trim() is a php command that trims whitespace if there is any surrounding your variable. I found that the result never returned as 'false' until I used ltrim as there must have been whitespace around it.

Last edited by sparks (2011-06-29 14:32:02)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#20 2011-06-29 13:52:09

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: scratch.mit.edu/api

sparks wrote:

I needed my site to check the validity of a Scratch username and password and thought that people might like the php code.

Code:

$t1 = ltrim(file_get_contents('http://scratch.mit.edu/api/authenticateuser?username=' . $_POST['scratchUsername'] . '&password=' . $_POST['scratchPassword']));
            if($t1 == 'false'){
                echo "The username or password you entered was incorrect!";
            }
            else{
                echo "Username and password correct!";
            }
        }

Your POST names may of course differ and the echo message can be changed to anything but this works very neatly!

file_get_contents() is a php command I found that pulls the contents of an entire file into a variable string for your use.

ltrim() is a php command that trims whitespace if there is any surrounding your variable. I found that the result never returned as 'false' until I used ltrim as there must have been whitespace around it.

Isn't ltrim only for the first characters, and 'trim' for the first and last?

Offline

 

#21 2011-06-29 14:31:31

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: scratch.mit.edu/api

You're absolutely right! I looked up the method in a hurry! I shall change it  smile  (It still works in this situation though).


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#22 2011-06-29 15:23:59

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: scratch.mit.edu/api

sparks wrote:

You're absolutely right! I looked up the method in a hurry! I shall change it  smile  (It still works in this situation though).

Nice to see that you're learning PHP anyway! It took me a while before I got the motivation  smile

Offline

 

#23 2011-06-29 15:28:05

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: scratch.mit.edu/api

I've known php for about two months now, but obviously knowing php means you understand the syntax and know enough of the commands to get by! As soon as something new comes along I have to look it up and learn that too!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

Board footer