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

#26 2011-07-18 16:55:35

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

Re: My new online/offline API for the fora

I should think so! Would you like me to give it a go? I have a feeling that it's more or less the same technique.... I can probably get it to echo back your Scratch icon image or an icon of your newest project(s) but I can't see any way of resizing them, I assume you'd want them smaller than they are on your mystuff page?


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

Offline

 

#27 2011-07-18 16:57:53

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

Re: My new online/offline API for the fora

sparks wrote:

I should think so! Would you like me to give it a go? I have a feeling that it's more or less the same technique.... I can probably get it to echo back your Scratch icon image or an icon of your newest project(s) but I can't see any way of resizing them, I assume you'd want them smaller than they are on your mystuff page?

Hmm... What's your API's code? I could try myself...

Last edited by SeptimusHeap (2011-07-18 16:58:05)


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

Offline

 

#28 2011-07-18 17:06:02

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

Re: My new online/offline API for the fora

The current php code for the API

Code:

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

Last edited by sparks (2011-07-18 17:48:43)


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

Offline

 

#29 2011-07-18 17:09:54

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

Re: My new online/offline API for the fora

sparks wrote:

Sure thing, here's the current code:

Code:

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

I originally had it echoing an <img> tag but it wan't working so be sure to use the echo file_get_contents() instead!  smile

Umm...

You can try making it, never mind.  wink   tongue

BTW, look at my sig   big_smile             vvvvvvvvvvvvvvvvvvv

Last edited by SeptimusHeap (2011-07-18 17:11:45)


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

Offline

 

#30 2011-07-18 17:11:49

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

Re: My new online/offline API for the fora

Haha, it's php. But surprisingly similar to the Smalltalk way of doing it! What exactly would you like the API to do?

Love it! What's it like when you're offline?

Last edited by sparks (2011-07-18 17:12:09)


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

Offline

 

#31 2011-07-18 17:13:47

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

Re: My new online/offline API for the fora

sparks wrote:

Haha, it's php. But surprisingly similar to the Smalltalk way of doing it! What exactly would you like the API to do?

Love it! What's it like when you're offline?

IDK, user pic and newest project.

http://img196.imageshack.us/img196/8804/offlineiw.png

By the way, the fonts are Andy Bold (Terraria), Minecraft, and Scratch  big_smile

Last edited by SeptimusHeap (2011-07-18 17:16:33)


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

Offline

 

#32 2011-07-18 17:14:11

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

Re: My new online/offline API for the fora

You should make it so it shows which block library librarians are online  wink   tongue


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

Offline

 

#33 2011-07-18 17:18:04

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

Re: My new online/offline API for the fora

done that already! Look at the first post of the library thread!


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

Offline

 

#34 2011-07-18 17:20:45

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

Re: My new online/offline API for the fora

SeptimusHeap wrote:

sparks wrote:

Haha, it's php. But surprisingly similar to the Smalltalk way of doing it! What exactly would you like the API to do?

Love it! What's it like when you're offline?

IDK, user pic and newest project.

http://img196.imageshack.us/img196/8804/offlineiw.png

By the way, the fonts are Andy Bold (Terraria), Minecraft, and Scratch  big_smile

So, what do you think of my sig/ideas?

Edit: just went offline, it works  big_smile

Last edited by SeptimusHeap (2011-07-18 17:21:52)


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

Offline

 

#35 2011-07-18 17:23:31

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

Re: My new online/offline API for the fora

It's pretty cool! The Scratch API lets you read information off the main Scratch site so a forum API that reads information from the fora (and maybe the site) would be cool! The sign looks... yummy! For some reason I feel it would taste really nice! The graphics are waaay better than my sig  tongue  I think using two fonts for septimus looks a little odd though...

You were saying about latest projects as images? Is that all you want me to try or do you have other expansion ideas?


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

Offline

 

#36 2011-07-18 17:25:09

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

Re: My new online/offline API for the fora

sparks wrote:

It's pretty cool! The Scratch API lets you read information off the main Scratch site so a forum API that reads information from the fora (and maybe the site) would be cool! The sign looks... yummy! For some reason I feel it would taste really nice! The graphics are waaay better than my sig  tongue  I think using two fonts for septimus looks a little odd though...

You were saying about latest projects as images? Is that all you want me to try or do you have other expansion ideas?

I think this works for showing if people are online alltogether  smile


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

Offline

 

#37 2011-07-18 17:25:50

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

Re: My new online/offline API for the fora

sparks wrote:

It's pretty cool! The Scratch API lets you read information off the main Scratch site so a forum API that reads information from the fora (and maybe the site) would be cool! The sign looks... yummy! For some reason I feel it would taste really nice! The graphics are waaay better than my sig  tongue  I think using two fonts for septimus looks a little odd though...

You were saying about latest projects as images? Is that all you want me to try or do you have other expansion ideas?

Userpic, newest favorite... newest friend?


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

Offline

 

#38 2011-07-18 17:26:09

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

Re: My new online/offline API for the fora

Yeah, my original use for this was the block library, I think it could be very handy for any thread with a "developers" list on the first post.


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

Offline

 

#39 2011-07-18 17:28:27

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

Re: My new online/offline API for the fora

sparks wrote:

Yeah, my original use for this was the block library, I think it could be very handy for any thread with a "developers" list on the first post.

Yeah. I'm going to to suggest this get ITopiced.


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

Offline

 

#40 2011-07-18 17:28:31

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

Re: My new online/offline API for the fora

SeptimusHeap wrote:

Userpic, newest favorite... newest friend?

The limitation with this API is that if you want it to show on the fora it has to be an image. Therefore it either has to be an image of some predetermined text or it has to be, say, the user image of your newest friend. (I think - it might be possible to insert text with it but the Scratch forums are generally pretty locked when it comes to getting stuff to change in a post...


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

Offline

 

#41 2011-07-18 17:29:46

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

Re: My new online/offline API for the fora

SeptimusHeap wrote:

sparks wrote:

Yeah, my original use for this was the block library, I think it could be very handy for any thread with a "developers" list on the first post.

Yeah. I'm going to to suggest this get ITopiced.

That's very kind of you, we'll see how useful I can make this though, currently the API is a little limited  smile


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

Offline

 

#42 2011-07-18 17:30:54

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

Re: My new online/offline API for the fora

sparks wrote:

SeptimusHeap wrote:

Userpic, newest favorite... newest friend?

The limitation with this API is that if you want it to show on the fora it has to be an image. Therefore it either has to be an image of some predetermined text or it has to be, say, the user image of your newest friend. (I think - it might be possible to insert text with it but the Scratch forums are generally pretty locked when it comes to getting stuff to change in a post...

Yeah... I don't think that would be too useful anyway.

I wonder, for the newest project/favorite one, if you could set up a php redirect script on a webpage to redierect to your newest project, along with showing an image...

Last edited by SeptimusHeap (2011-07-18 17:31:47)


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

Offline

 

#43 2011-07-18 17:37:41

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

Re: My new online/offline API for the fora

Should be possible, it would have to take you to that page first so the redirect would take a second or so, but the existing "newest project" API should be able to supply the redirect link...


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

Offline

 

#44 2011-07-18 17:51:19

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

Re: My new online/offline API for the fora

Cool! So, you think you could make it?

And I fixed my sig.


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

Offline

 

#45 2011-07-18 17:55:28

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

Re: My new online/offline API for the fora

Looks good! I will look into it tomorrow, certainly, it's on the updates list on the main post!


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

Offline

 

#46 2011-07-18 18:01:14

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

Re: My new online/offline API for the fora

Cool  big_smile

How's Panther 1.1 going? It's been a long time... [/Portal2reference]


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

Offline

 

#47 2011-07-18 18:04:29

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

Re: My new online/offline API for the fora

SeptimusHeap wrote:

Cool  big_smile

How's Panther 1.1 going? It's been a long time... [/Portal2reference]

I got the refrence  tongue  and slowly...


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

Offline

 

#48 2011-07-18 18:05:26

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

Re: My new online/offline API for the fora

Why isn't it working for me?  sad


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

Offline

 

#49 2011-07-18 18:11:39

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

Re: My new online/offline API for the fora

Hmmm, no idea! Could you post the images normally here? I'll take a look.

EDIT: if you look at it as a link you can see the error. It looks like it can't find your images.

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


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

Offline

 

#50 2011-07-18 18:16:07

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

Re: My new online/offline API for the fora

For user icon you can use [img]http://scratch.mit.edu/static/icons/buddy/USER ID (found on friends list url)_sm.png[/img]

Sparks' current icon: http://scratch.mit.edu/static/icons/buddy/183006_sm.png

(If he changes it, the changes will show.)

Last edited by SeptimusHeap (2011-07-18 18:18:18)


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

Offline

 

Board footer