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

#701 2012-09-12 13:59:57

dvd4
Scratcher
Registered: 2010-06-30
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

zubblewu wrote:

Nice api  big_smile


I made a mod  big_smile  It's called blook!
http://i49.tinypic.com/16ia63p.png

Offline

 

#702 2012-09-19 16:05:28

MrFlash67
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: ITopic: self-updating images and links in posts!

I am having trouble. I am trying to mix three users online and text.

Code:

 [url]http://blocks.scratchr.org/API.php?
user=one&user2=two&user3=three&action=onlineStatus&type=text[/url]

What am I doing wrong?


Who would win, SOPA or PIPA?

Offline

 

#703 2012-09-19 16:15:40

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

MrFlash67 wrote:

I am having trouble. I am trying to mix three users online and text.

Code:

 [url]http://blocks.scratchr.org/API.php?
user=one&user2=two&user3=three&action=onlineStatus&type=text[/url]

What am I doing wrong?

use the img tag instead of the url tag:

Code:

[img]http://blocks.scratchr.org/API.php?
user=one&user2=two&user3=three&action=onlineStatus&type=text[/img]

Just replace user1 user 2, etc with the usernames


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#704 2012-09-19 16:52:41

MrFlash67
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: ITopic: self-updating images and links in posts!

SJRCS_011 wrote:

MrFlash67 wrote:

I am having trouble. I am trying to mix three users online and text.

Code:

 [url]http://blocks.scratchr.org/API.php?
user=one&user2=two&user3=three&action=onlineStatus&type=text[/url]

What am I doing wrong?

use the img tag instead of the url tag:

Code:

[img]http://blocks.scratchr.org/API.php?
user=one&user2=two&user3=three&action=onlineStatus&type=text[/img]

Just replace user1 user 2, etc with the usernames

Now I'm using img and it still won't work. Look in my sig for what I have.

Last edited by MrFlash67 (2012-09-19 16:53:15)


Who would win, SOPA or PIPA?

Offline

 

#705 2012-09-19 18:16:37

MrFlash67
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: ITopic: self-updating images and links in posts!

I now have

Code:

[img]http://blocks.scratchr.org/API.php?
action=onlineStatus&user=User1&user2=User2&user3=User3&type=text&target=all[/img]

Last edited by MrFlash67 (2012-09-19 19:05:48)


Who would win, SOPA or PIPA?

Offline

 

#706 2012-09-19 21:15:41

MrFlash67
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: ITopic: self-updating images and links in posts!

What image format does the text use?


Who would win, SOPA or PIPA?

Offline

 

#707 2012-09-20 00:52:56

MrFlash67
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: ITopic: self-updating images and links in posts!

The multi-user stuff is for if ONE of them is on, not all, right?


Who would win, SOPA or PIPA?

Offline

 

#708 2012-09-20 03:25:10

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

Re: ITopic: self-updating images and links in posts!

MrFlash67 wrote:

What image format does the text use?

The png file format. If you still want to learn more, I suppose you could read here.

Offline

 

#709 2012-09-20 03:27:15

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

Re: ITopic: self-updating images and links in posts!

MrFlash67 wrote:

The multi-user stuff is for if ONE of them is on, not all, right?

Yes, as sparks said, "If any of them are online, the image returned will be the online image."  smile

Offline

 

#710 2012-10-16 18:46:43

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

Thanks! I can't decide which image to use in my signatue, so I'll use the random!
And btw, my newest project is: http://blocks.scratchr.org/API.php?user=Mokat&action=projects&type=newest&return=image&num=1


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#711 2012-10-16 19:11:16

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

@zubblewut
Can you give me the code for your signature?


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#712 2012-10-21 06:54:28

Willpower
Scratcher
Registered: 2012-01-26
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

sparks wrote:

I-Topic: Self Updating Images In Posts And Sigs     

This API allows Scratch users to show images that change according to events and conditions in their forum posts and signatures. This includes showing whether the user is online or not and displaying their newest project(s).
___________________________________________________________________________________
Examples of using the API:
I am currently http://blocks.scratchr.org/API.php?user … ype=square http://blocks.scratchr.org/API.php?user … ;type=text and my newest project is called http://www.blocks.scratchr.org/API.php? … &num=1. Click on the thumbnail to view it: http://blocks.scratchr.org/API.php?user … &num=1
___________________________________________________________________________________
This API is open source! Look at post #2 for the most recent php code!
___________________________________________________________________________________
Create your custom link/image using the creator linked and documented here by comp500 or make it yourself using the uses list below.

Uses list. Click one to be taken to the documentation page.
Online/offline indicator
     - Online offline circle/square
     - Online offline custom images
     - Online offline custom URLs
Newest project thumbnail(s)/link(s)/info
     - Thumbnail image
     - Link
     - Name
     - Number of love-it's
     - Number of views
     - Number of comments
     - Number of favouriters
     - Number of remixers
     - Number of downloads
newest friend user image(s)
     - Newest friend user icon image(s)
     - Newest friend mystuff page link(s)
Random
     - Random Images
     - Random Links
Customise any text return to match your sig
___________________________________________________________________________________
Thanks to MathWizz for help getting the images to display on the fora!

EDIT- Whoops quoted this by accident, I meant to use some of it. Might as well make the most of this post...

Great work Sparks!

Last edited by Willpower (2012-10-21 06:55:34)


http://i49.tinypic.com/e84kdj.png

Offline

 

#713 2012-11-02 12:13:16

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

How do you do latest project?


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#714 2012-11-02 12:34:18

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

Re: ITopic: self-updating images and links in posts!

mythbusteranimator wrote:

How do you do latest project?

this post explains it all!

Quote this post to see the code for this:

mythbusteranimator's newest project is called http://blocks.scratchr.org/API.php?user=mythbusteranimator&action=projects&type=newest&return=text&num=1


and looks like this (click the image to go to the project): http://blocks.scratchr.org/API.php?user=mythbusteranimator&action=projects&type=newest&return=image&num=1


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

Offline

 

#715 2012-11-02 12:36:49

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

sparks wrote:

mythbusteranimator wrote:

How do you do latest project?

this post explains it all!

Quote this post to see the code for this:

mythbusteranimator's newest project is called http://blocks.scratchr.org/API.php?user … &num=1


and looks like this (click the image to go to the project): http://blocks.scratchr.org/API.php?user … &num=1

Oh. Epic.  tongue


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#716 2012-11-02 14:03:15

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: ITopic: self-updating images and links in posts!

Sparks, if you said "Oh wow. I've just realised how much smaller I can make my api code now..." did you mean that it was about (making up a number) 2000 lines and you could shorten it to about 950? I don't know PHP, but in Lua iteration takes a lot of lines if you're using letters, so I guess somthing similar would be the same length in PHP.


I'm back.
Maybe.

Offline

 

#717 2012-11-02 14:46:01

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

Re: ITopic: self-updating images and links in posts!

Well, for example, here's the piece of API code that loads the n'th newest friend's profile icon:

Code:

$page = ltrim(file_get_contents('http://scratch.mit.edu/api/getfriendsbyusername/' . $inUser));
            $count = '0';
            $placeholder = '0';
            while ($count < $_GET['num'] - '1'){
                $placeholder = strpos($page, ':', $placeholder + '1');
                $count ++;
            }
            if($count > 0){
                $placeholder++;
            }
            $endplaceholder = strpos($page, ':', $placeholder + 1);
            if($inReturn == 'image'){
            #echo "<img src = 'http://scratch.mit.edu/static/icons/buddy/" . substr($page, $placeholder, $endplaceholder - $placeholder) . "_sm.png' />"; < this echoes the image rather than the file. For glitch testing.
            echo file_get_contents('http://scratch.mit.edu/static/icons/buddy/' . substr($page, $placeholder, $endplaceholder - $placeholder) . '_sm.png');
            header("Content-Type: image/gif");
}

a lot of that is counting n steps into the list of friend id's it's pulled up. With explode I can probably do this:

Code:

$page = ltrim(file_get_contents('http://scratch.mit.edu/api/getfriendsbyusername/' . $inUser));
            $friends = explode(";", $page);
            $num = $_GET['num'];
            $friend = $friends[$num];
            if($inReturn == 'image'){
            #echo "<img src = 'http://scratch.mit.edu/static/icons/buddy/" . $friend . "_sm.png' />"; < this echoes the image rather than the file. For glitch testing.
            echo file_get_contents('http://scratch.mit.edu/static/icons/buddy/' . $friend . '_sm.png');
            header("Content-Type: image/gif");
}

I've not tried this, and have only just understood the function, but it seems to me that this would work, reducing that part of the code from 16 lines to 9!

Last edited by sparks (2012-11-02 14:47:20)


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

Offline

 

#718 2012-11-02 14:49:56

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: ITopic: self-updating images and links in posts!

So explode() removes iteration? If only there was a function like that in Lua....


I'm back.
Maybe.

Offline

 

#719 2012-11-02 15:13:54

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

Re: ITopic: self-updating images and links in posts!

Er, no. Explode creates an array out of a string using a seperator. Here's an example:

$input = 'tomatoes,beans,crisps,lettuce,crackers';// a string
$list = explode(",", $input); // explode the string $input using "," as a separator.
echo $list[0]; // echoes "tomatoes".
echo $list[1]; //echoes "beans".
echo $list[3]; //echoes "lettuce".

In the case of the code in the API, friend Id's are listed on a page, separated by a ":". The explode function writes each friend Id to an array. then $friend[n] can be called.

Does that make sense?

Last edited by sparks (2012-11-02 15:14:47)


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

Offline

 

#720 2012-11-02 15:18:16

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: ITopic: self-updating images and links in posts!

sparks wrote:

Er, no. Explode creates an array out of a string using a seperator. Here's an example:

$input = 'tomatoes,beans,crisps,lettuce,crackers';// a string
$list = explode(",", $input); // explode the string $input using "," as a separator.
echo $list[0]; // echoes "tomatoes".
echo $list[1]; //echoes "beans".
echo $list[3]; //echoes "lettuce".

In the case of the code in the API, friend Id's are listed on a page, separated by a ":". The explode function writes each friend Id to an array. then $friend[n] can be called.

Does that make sense?

OHHHHHHH I see now. It's like the BYOB block that turns a string into a list with a [ ] as input.


I'm back.
Maybe.

Offline

 

#721 2012-11-02 15:20:27

Willpower
Scratcher
Registered: 2012-01-26
Posts: 1000+

Re: ITopic: self-updating images and links in posts!

sparks wrote:

Er, no. Explode creates an array out of a string using a seperator. Here's an example:

$input = 'tomatoes,beans,crisps,lettuce,crackers';// a string
$list = explode(",", $input); // explode the string $input using "," as a separator.
echo $list[0]; // echoes "tomatoes".
echo $list[1]; //echoes "beans".
echo $list[3]; //echoes "lettuce".

In the case of the code in the API, friend Id's are listed on a page, separated by a ":". The explode function writes each friend Id to an array. then $friend[n] can be called.

Does that make sense?

i'm guessing that will not work for the random sig API?


http://i49.tinypic.com/e84kdj.png

Offline

 

#722 2012-11-02 15:39:12

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

Re: ITopic: self-updating images and links in posts!

Willpower wrote:

i'm guessing that will not work for the random sig API?

No, but the random sig section just randomly chooses one of the image URL's in the URL of the API to display so there was no string separation required for that part.


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

Offline

 

#723 2012-11-02 15:51:23

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: ITopic: self-updating images and links in posts!

sparks wrote:

Willpower wrote:

i'm guessing that will not work for the random sig API?

No, but the random sig section just randomly chooses one of the image URL's in the URL of the API to display so there was no string separation required for that part.

So the URLs are an input that (going to use Scratch as an example) go into a list, and then
report (item(pick random (1) to (length of [urllist]) of [urllist])
right?


I'm back.
Maybe.

Offline

 

#724 2012-11-02 15:55:41

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

Re: ITopic: self-updating images and links in posts!

That's correct!  smile

(I'm just moving this over to the API topic - it's off topic here  tongue  )


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

Offline

 

#725 2012-11-02 16:05:26

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: ITopic: self-updating images and links in posts!

Ok then. I see! But as I don't know PHP, it's kinda unneeded by me. But still, it's helpful if I ever decide to learn PHP!

(o.o My IE decided to copy and paste randomly)


I'm back.
Maybe.

Offline

 

Board footer