Skip to content
TORNLIFE More

Use API in forum?

Started by Xradiation [2254540] on in API Development.

8 replies · 190 views · thread synced · 10 days ago · View on torn.com
About this thread

Posts archived: 9 / 9 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
9
Discussion span
→
People posting
7
Likes on archived posts
9
Posts by staff, officers and moderators
2
Authority score
72 / 100
Historical score
22 / 100
Story score
32 / 100
Engagement score
55 / 100

Most-liked replies

Mentioned in this thread

Bug [1455582] ×1

Xradiation [2254540]
I have seen a few guides where they show if the player is okay or in hospital. How do they do this.
And is it possible to to use php in a thread, or do you need to use another language?
thanks in advance.
LouBaker [1162207]
I would like to know how the above is done, the red and green icons change on refreshing the page

surely it's not possible to refresh every icon the list like this with API's

How is this Done, how does it work
Father [2131687]
I remember asking Baldr about this. He told me that this is provided by Bug and he himself didn't know the details . My estimate is that Bug hosts those small light images on his server. Those images change colour with respect to the time left in Hospital. Each image seperate for individual targets. Just like you see factions having graphics of live perks updated through API.

And it is not necessary that the API calls to check the status are made simultaneously. Maybe he has coded it in a way to check status of X number of targets in first minute and next X number of targets in the next minute. This way you can easily avoid crossing the limit.

Mentions: Bug [1455582]

Xradiation [2254540]
I figured it out, sort off.
You use imagecreatefrompng to create green picture if player online, else you create an red picture.
Then you host the script on a site, get the url.
And use the bbcode [.image]url[/image.] (without the dot)

Some code to see if your company is recruiting:
(but you need to place arial.ttf in the same path as the code)
Baldr [1847600] Reporter
Bug has a server set up to do this. When you load the page, the images come from his server, and he has it set up to send the red, green, orange, or purple image depending on their status. Red for hosp, Orange for hosp but close to getting out, green for not in hosp, and purple for "other". The purple is used if that person isn't in the system yet and isn't being polled, mostly when I add new targets to the list.  There may be other reasons for that purple "unknown" status, but that's the one that I know about.

I know one of the tricks is that when you poll one of those people and they are in the hospital, it tells you for how long.  All of the targets in that leveling thread are inactive, so they won't be medding out of the hospital.  If it says the guy will be there for 17 minutes and 25 seconds, you store that information, then during that time, you do not need to poll his API again, you just return the Red icon.  When he gets down to a short amount of time, you start showing him with an Orange icon.  When his hosp time reaches zero, you add him back in with the green icon people.

Not needing to poll them when they are Red helps cut down on the # of API calls, and I would assume, it cuts out a lot of them.  Very useful since you have a limit.

The ones showing green, not in hospital, need to be polled more often.  They could be hit at any time, and they will keep showing Green until you check their API again after that hit.

With active players, who might get a revive or med out, it's more difficult since you have to keep checking them even when they are red.
Bug [1455582] Committee Committee
Long story short, I'm a f**king wizard!! :)

But yeah, Baldr had a pretty good explanation of how it's done. My server looks at the URL its receiving and serves the appropriately coloured image for whatever users ID it is sent. It changes each time because I disable image caching, adds more strain to my server but keeps it live.

Thanks to the efficiency tricks mentioned above, it doesnt take many API calls to keep it up to date. It's also updating on a timer rather than everytime you load them (which would be slow).

The only detail missing from this thread is that I wrote my own Java web server to serve the images, but you could just as easily do it in PHP with a cron task :)