I am having trouble. I am trying to mix three users online and text.
[url]http://blocks.scratchr.org/API.php? user=one&user2=two&user3=three&action=onlineStatus&type=text[/url]
What am I doing wrong?
Offline
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:
[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
Offline
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)
Offline
I now have
[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)
Offline
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
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."
Offline
@zubblewut
Can you give me the code for your signature?
Offline
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)
Offline
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
and looks like this (click the image to go to the project):
Offline
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.
Offline
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.
Offline
Well, for example, here's the piece of API code that loads the n'th newest friend's profile icon:
$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:
$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)
Offline
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)
Offline
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.
Offline
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?
Offline
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.
Offline
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?
Offline
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)
Offline