Discuss Scratch

sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

Hello everyone! That's right I'm still alive! I've been getting one or two people asking me whether the random images and links in signatures are still working and the answer is yes!

Since the old thread is gone, (thanks to jvvg for zipping and preserving this thread) I've decided to repost it here for reference. Some parts of this API are currently broken as they point to old pages. I'll be updating this API as I go. Since I'll probably be in the mood as a result of this, suggesting new API features might be a good idea! (number of posts will not be added, I've discussed this with the Scratch team and it was hidden for a reason) :)

I'm also updating my documentation for the API functions, taking a note of the layout that php.net uses to make things clearer and easier to use. Feel free to input suggestions on making things clear! Eschew obfuscation, espew elucidation, as they say!

Current Status: rebuilding post from old forum

~Sparks

────────────────────────────────────────────────────────────────────────────

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 and my latest project is called . You can click on the thumbnail picture to view it:

────────────────────────────────────────────────────────────────────────────
This API is open source! Look at post #2 for the most recent php code!
────────────────────────────────────────────────────────────────────────────

List of API functions. Click one to see the documentation and view examples:

Online/offline indicator
  • Square/circle/text indicator
  • Custom images
  • Custom links
  • Check for multiple users

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!

Last edited by sparks (Feb. 20, 2014 14:23:05)

sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

The current code for the API goes here soon
sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

^Home

Function: userStatus
────────────────────────────────────────────────────────────────────────────
Description
www.blocks.scratchr.org/API.php?action=userStatus&user=sparks
Returns the online status of user user
────────────────────────────────────────────────────────────────────────────

Examples
Example #1 - Returning a status dot or text

The [type] parameter is required here. If the parameter isn't specified it defaults to round which will return a circular online or offline image. However you can set the [type] parameter to square ( and ) or text ( and ).

www.blocks.scratchr.org/API.php?action=userStatus&user=sparks&type=square

will return or
www.blocks.scratchr.org/API.php?action=userStatus&user=sparks&type=text

will return or

Example #2 - Displaying a specific image based on online status

The [online] and [offline] parameters are required here, however the [type] parameter can be left out.

www.blocks.scratchr.org/API.php?action=userStatus&user=sparks&online=scratchdoesntcurrentlylikeimageshack1&offline=scratchdoesntcurrentlylikeimageshack2

will return scratchdoesntcurrentlylikeimageshack1 or scratchdoesntcurrentlylikeimageshack2, two custom images.
Note: If either the [online] or [offline] parameters are left out, the image for their status will default to round

Example #3 - Creating an online/offline dependant URL

This requires the otherwise unused [return] parameter. If not used, [return] defaults to image but setting it to link will redirect the user to the specified link. Remember to place this inside an url tag not an img tag.
www.blocks.scratchr.org/API.php?action=userStatus&user=sparks&return=link&online=http://www.accidentalgames.com&offline=http://mv.ezproxy.com.ezproxyberklee.flo.org/users/sparks

Will return a link to my website if I'm online and to my profile if I'm offline.

Example #4 - Checking for multiple users at once

You can check up to a total of four users at once using the [user2], [user3] and [user4] parameters. These additional user checkers can be applied to any of the above examples. The API will consider the return to be online if one or more users are found to be online.

www.blocks.scratchr.org/API.php?action=userStatus&user=sparks&user2=lightnin&user3=Paddle2See&user4=jvvg

will return a if any of the four users sparks. lightnin, Paddle2See or jvvg are online.

────────────────────────────────────────────────────────────────────────────

Parameters
parameters marked with [square brackets] are optional

user
The username of the user to check. Case sensitive.

[user2] [user3] [user4]
Used to check up to another three usernames. The API will return as online if any one of the specified users is online. Case sensitive.

[type]
The return type if you want a coloured dot. Must be: round, square or text. Defaults to round if not specified.

[online]
If you want a specific image to appear when user is online then the URL for the image goes here.

[offline]
If you want a specific image to appear when user is offline then the URL for the image goes here.

[return]
If you want to use the userStatus function as a link rather than an image then use this by setting [return] to link. Defaults to image if not specified.

────────────────────────────────────────────────────────────────────────────
^Home

Last edited by sparks (Feb. 20, 2014 15:55:27)

sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

Newest project thumbnails/links/info documentation goes here
sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

Newest friend/user images documentation goes here
sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

Random images/links documentation goes here
sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

customising text returns documentation goes here
sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

Another space in case I need it
sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

Understanding and using the API

Glossary
API (Application Programming Interface) - An application that lets users or another piece of code interact with something else.
Function - a task or process to perform, Getting the online status of a user, for example.
Parameter - Another name for variable. Examples of API parameters are the name of a user or the link to redirect to.

────────────────────────────────────────────────────────────────────────────

Reading the API documentation

Parameters are marked in blue text like these: user, [return] whenever they are referred to. If you see blue text, its a parameter. Parameters are inputs that tell the API specifically what you want it to do. To see a list of parameters a particular function can use, scroll to the bottom of the documentation post for that function.

Examples contain an example link showing how an API function can be used in grey text with a description above. These are examples to show how an API link should be laid out and can easily be modified.


────────────────────────────────────────────────────────────────────────────

Using the API

The API takes the form of a URL which you can place into an [img] or [url] tag, either in a post or in your forum signature.

Syntax
Parameters are seperated by an & symbol. If you want to enter & as a text character type %26 instead. Spaces cannot be entered into an URL, use either an underscore( _ ) or %20 for spaces.

Last edited by sparks (Feb. 20, 2014 16:01:47)

PullJosh
Scratcher
1000+ posts

Self Updating Images and Links in Posts

Oh, nice! Glad to see this is back.
blob8108
Scratcher
1000+ posts

Self Updating Images and Links in Posts

sparks wrote:

^Home
Use http://scratch.mit.edu.ezproxyberklee.flo.org/discuss/topic/30239/?page=1#post-259769 for the home links, so it doesn't reload the whole page.
QuillzToxic
Scratcher
1000+ posts

Self Updating Images and Links in Posts

I think I made dis before u XD
So Duplicate…

But if you wish you can close mine XD

3rd non-op post DDDDDDDDDDDDD

Last edited by QuillzToxic (Feb. 23, 2014 15:47:06)

sparks
Forum Moderator
100+ posts

Self Updating Images and Links in Posts

QuillzToxic wrote:

I think I made dis before u XD
So Duplicate…

But if you wish you can close mine XD

3rd non-op post DDDDDDDDDDDDD
Yeah, I kinda noticed you'd done a thread about the API once I started again here. I hope you don't mind? Thing is the API is kinda broken atm for the new Scratch version and I figured that I should rewrite the documentation properly for the fixes.

blob8108 wrote:

Use http://scratch.mit.edu.ezproxyberklee.flo.org/discuss/topic/30239/?page=1#post-259769 for the home links, so it doesn't reload the whole page.
Thanks for the tip! That's awesome!
QuillzToxic
Scratcher
1000+ posts

Self Updating Images and Links in Posts

sparks wrote:

QuillzToxic wrote:

I think I made dis before u XD
So Duplicate…

But if you wish you can close mine XD

3rd non-op post DDDDDDDDDDDDD
Yeah, I kinda noticed you'd done a thread about the API once I started again here. I hope you don't mind? Thing is the API is kinda broken atm for the new Scratch version and I figured that I should rewrite the documentation properly for the fixes.

blob8108 wrote:

Use http://scratch.mit.edu.ezproxyberklee.flo.org/discuss/topic/30239/?page=1#post-259769 for the home links, so it doesn't reload the whole page.
Thanks for the tip! That's awesome!
Its ok

When I figure out how to learn php and finish learning it I'll help


Edit: Wouldent it be nice if the online/offline would co-op into the comment system or on you profile

Last edited by QuillzToxic (Feb. 25, 2014 06:47:22)

technoboy10
Scratcher
1000+ posts

Self Updating Images and Links in Posts

Looks like the full user list should be coming sometime in the future… https://github.com/LLK/s2forums/issues/1032

Powered by DjangoBB