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

#1 2011-07-17 14:15:49

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

My new online/offline API for the fora

This thread is closed and the information below is outdated, please don't use it. Instead, the newer version can be found here!
________________________________________________________________________________
Hello everyone! I've just finished building a little API page which returns either one image or another depending on whether of not the requested Scratch user is online on the forums! I couldn't find any API that did this so decided to make it myself!

________________________________________________________________________________
This API is open source! Click here to see the current API code!
________________________________________________________________________________
parameters: user, optional(type, online, offline)
the API is case sensitive to all parameters
________________________________________________________________________________

Standard image
For this type you need only give the Scratcher name. This will either show a http://blocks.scratchr.org/online.gif or a http://blocks.scratchr.org/offline.gif. For example: I am currently http://blocks.scratchr.org/libstatus.php?user=sparks.

Code:

[img]http://blocks.scratchr.org/libstatus.php?user=user[/img]

________________________________________________________________________________

The type attribute
The "type" attribute can be set to change the appearance of the image returned. setting type to square gives you http://blocks.scratchr.org/onlineSquare.gif and http://blocks.scratchr.org/offlineSquare.gif. Setting it to "text" will give you the text http://blocks.scratchr.org/onlineText.gif and http://blocks.scratchr.org/offlineText.gif (they're still images).For example: I am currently http://blocks.scratchr.org/libstatus.php?user=sparks&type=squarehttp://blocks.scratchr.org/libstatus.php?user=sparks&type=text

Code:

[img]http://blocks.scratchr.org/libstatus.php?user=user&type=type[/img]

________________________________________________________________________________

The link attributes
These two attributes allow you to link your own images through the API. You can use it to make a signature that appears different when you are offline to online, for example!

Code:

[img]http://blocks.scratchr.org/libstatus.php?user=sparks&online=onlineimagelink&offline=offlineimagelink[/img]

This takes two image you like, hosted anywhere on the internet as a supported image type. For example I could take this: http://www.burtonmutualangling.com/images/online.png and this: http://www.glam-ou-rama.co.uk/forum/images9/offline.png to get this:

http://blocks.scratchr.org/libstatus.php?user=sparks&online=http://www.burtonmutualangling.com/images/online.png&offline=http://www.glam-ou-rama.co.uk/forum/images9/offline.png Sparks.
________________________________________________________________________________
Planned updates
User image display grabs image from their my stuff page.
Latest project(s) thumbnail display.
redirect to latest project(s) page.

Please suggest other ideas.

Thanks to MathWizz for help getting the images to display in a post!

Last edited by sparks (2011-07-20 09:47:03)


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

Offline

 

#2 2011-07-17 14:19:51

dav09
Scratcher
Registered: 2009-03-25
Posts: 1000+

Re: My new online/offline API for the fora

Its kinda pointless but still cool and it can be used in your signature to judge if your online or not.  smile

Offline

 

#3 2011-07-17 14:21:36

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

Re: My new online/offline API for the fora

dav09 wrote:

Its kinda pointless but still cool and it can be used in your signature to judge if your online or not.  smile

Yup, I was aiming for use either in sigs or on collab threads where the circle could appear next to each listed developers' name  smile


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

Offline

 

#4 2011-07-18 06:39:34

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: My new online/offline API for the fora

dav09 wrote:

Its kinda pointless but still cool and it can be used in your signature to judge if your online or not.  smile

why would you need to put that in a sig when it already says if ur online/offline.


http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&display=small

Offline

 

#5 2011-07-18 06:43:37

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

Re: My new online/offline API for the fora

nathanprocks wrote:

dav09 wrote:

Its kinda pointless but still cool and it can be used in your signature to judge if your online or not.  smile

why would you need to put that in a sig when it already says if ur online/offline.

To make it more apparent? You could also put it in your sig for other people, say people you interact with regularly to see quickly if they're online  smile


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

Offline

 

#6 2011-07-18 06:46:40

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

Re: My new online/offline API for the fora

It doesn't work  hmm  http://blocks.scratchr.org/libstatus.php?user=ssss


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

Offline

 

#7 2011-07-18 07:13:07

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

Re: My new online/offline API for the fora

ssss wrote:

It doesn't work  hmm  http://blocks.scratchr.org/libstatus.php?user=ssss

Right click and control click on "View Image". It should show there, but not embedded.
I think that's because the source of the page embeds the image, rather than drawing it.

Offline

 

#8 2011-07-18 07:15:48

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

Re: My new online/offline API for the fora

scimonster wrote:

Right click and control click on "View Image". It should show there, but not embedded.
I think that's because the source of the page embeds the image, rather than drawing it.

Yeah, how do you fix that?


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

Offline

 

#9 2011-07-18 07:32:51

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: My new online/offline API for the fora

Well if you view the page it works, just doesn't show it in your sig.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#10 2011-07-18 07:39:53

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

Re: My new online/offline API for the fora

markyparky56 wrote:

Well if you view the page it works, just doesn't show it in your sig.

That's not what I want though  wink


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

Offline

 

#11 2011-07-18 07:43:22

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

Re: My new online/offline API for the fora

I did say in the first post that it doesn't work... the thing is it USED to. Pages containing only images were displayed as images on the fora, daffy22's changing sig was an example of that...  sad


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

Offline

 

#12 2011-07-18 07:47:32

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

Re: My new online/offline API for the fora

Hmm.  Could you make it display text?


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

Offline

 

#13 2011-07-18 07:49:38

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

Re: My new online/offline API for the fora

No, I don't think Scratch will let you show text. I could do am image of text, but then we have the same problem.


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

Offline

 

#14 2011-07-18 10:15:09

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: My new online/offline API for the fora

Try this code:

Code:

<?php
header('content-type: image/gif'); 
$fora = file_get_contents('http://scratch.mit.edu/forums/index.php');
$page = ltrim($fora);
$startpos = strrpos ($page, "Online:&nbsp;</strong></dt>");
$endpos = strlen(ltrim($fora));
$refined = substr($page, $startpos, $endpos);
if(isset($_GET['user'])){
    $pos = strrpos($refined, $_GET['user']);
    if(strlen($pos < '1'))
        echo file_get_contents('http://blocks.scratchr.org/offline.gif');
    else
        echo file_get_contents('http://blocks.scratchr.org/online.gif');
}
?>

http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#15 2011-07-18 10:29:08

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

Re: My new online/offline API for the fora

Oh I see, echo the file rather than echo the img tag?! That sounds like it might work! I'll try it in a moment!


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

Offline

 

#16 2011-07-18 11:41:55

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

Re: My new online/offline API for the fora

It works! I am currently http://blocks.scratchr.org/libstatus.php?user=sparks&amp;type=text

Last edited by sparks (2011-07-18 13:48:25)


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

Offline

 

#17 2011-07-18 11:53:08

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

Re: My new online/offline API for the fora

sparks wrote:

It works! I am currently http://blocks.scratchr.org/libstatus.php?user=sparks

Cool! I'm http://blocks.scratchr.org/libstatus.php?user=scimonster
It's case sensitive though.

Offline

 

#18 2011-07-18 12:03:17

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

Re: My new online/offline API for the fora

Right, I'm going to add some options to the API  smile


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

Offline

 

#19 2011-07-18 12:17:28

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: My new online/offline API for the fora

Added to my sig. Woot!
What kind of options?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#20 2011-07-18 12:25:51

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

Re: My new online/offline API for the fora

love it!


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

Offline

 

#21 2011-07-18 12:47:33

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

Re: My new online/offline API for the fora

optional square online / offline status icon: http://blocks.scratchr.org/libstatus.php?user=sparks&amp;type=square

Last edited by sparks (2011-07-18 13:01:37)


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

Offline

 

#22 2011-07-18 12:53:59

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

Re: My new online/offline API for the fora

What does the page say when you go there?

Offline

 

#23 2011-07-18 12:55:47

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

Re: My new online/offline API for the fora

You know how if you open an image with a text editor you get a load of characters? That.


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

Offline

 

#24 2011-07-18 16:25:25

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

Re: My new online/offline API for the fora

The first post now documents the API fully, allowing status to be shown using a circle or square image, the text "online" or "offline" or even an image of choice hosted anywhere on the internet!


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

Offline

 

#25 2011-07-18 16:51:52

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: My new online/offline API for the fora

Could you by any chance use this same idea to make...

Signatures that would show your current icon
Your newest project (using RSS maybe?)

..etc?


http://i46.tinypic.com/dw7zft.png

Offline

 

Board footer