Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: [Example] Live League Game Signature Image

  1. #1
    Administrator
    Join Date
    Oct 2012
    Posts
    66

    Post [Example] Live League Game Signature Image

    I wanted to write up a few examples of WebAPI consumers, so I spent some of my free time coming up with this one.

    Source code and up-to-date description lives here: https://github.com/danieljennings/dota2webapiexamples


    Live League Game Signature Image

    This example is a feasible forum signature that will show forum-goers the currently-live league matches occuring on Dota 2 at the time. It will rotate through all of the live league games, giving each one 3.5 seconds of visibility before moving onto the next and wrapping back around to the first.

    This image is an example of what the signature looks like, but is not live itself. Visit this link to see a live version.




    Requirements:


    Demonstrates:
    • WebAPI: GetLeagueListing
    • WebAPI: GetLiveLeagueGames
    • Caching: Using Memcached to reduce latency by caching WebAPI results
    • Images: Using ImageMagick to render images on-demand.



    Source code: https://github.com/danieljennings/do..._signature.php
    Last edited by DanielJ; 01-29-2013 at 06:51 PM.

  2. #2
    Basic Member jimmydorry's Avatar
    Join Date
    Dec 2012
    Posts
    814
    Great... except how often do we expect there to be league games on?

    A neat concept none-the-less.

  3. #3
    Basic Member jimmydorry's Avatar
    Join Date
    Dec 2012
    Posts
    814
    Sorry for double post.

    Looked a bit closer at the code.

    Why do you not use curl? File_get_contents does the job, but is not nearly as efficient (Can be more than 25% inefficient depending on number of requests). (Random Source http://stackoverflow.com/questions/5...er-performance)

    How efficient is the code (how many queries does it require?) when you instead want to make a live sig of who the players are in those games?

  4. #4
    Administrator
    Join Date
    Oct 2012
    Posts
    66
    Quote Originally Posted by jimmydorry View Post
    Great... except how often do we expect there to be league games on?

    A neat concept none-the-less.
    The concept wasn't the important part of the project, I just wanted to fit the pieces together and hopefully make it easier for new programmers or new WebAPI users to create something. :-)

    As far as Curl versus file_get_contents goes, I've always used file_get_contents and it has served me well enough. The code that I wrote would look different if I were trying to actually deploy it at any scale or ensure its maintainability.

    For the player listing, it looks like the players, spectators, and commentators are all listed by name in the GetLiveLeagueGames method, which means the data is available to this sample code already.

  5. #5
    Basic Member jimmydorry's Avatar
    Join Date
    Dec 2012
    Posts
    814
    Great. Thanks for the fast response. I am sure it will help someone.

  6. #6
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    Quote Originally Posted by DanielJ View Post
    For the player listing, it looks like the players, spectators, and commentators are all listed by name in the GetLiveLeagueGames method, which means the data is available to this sample code already.
    Last I checked (when there was a live game on), there's just a team ID that goes between 0 and 4 (at least). Mind posting the enum for that?

  7. #7
    Administrator
    Join Date
    Oct 2012
    Posts
    66
    Here's an example GetLiveLeagueGames response for testing: https://gist.github.com/4675491

    For the Team ID's, as far as I can tell:
    0 Radiant
    1 Dire
    2 Broadcaster
    3+ Spectator (not sure what the difference is here, but it probably doesn't matter)

  8. #8
    Basic Member Cyborgmatt's Avatar
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    389
    Nice, I was waiting for someone to make use of the new live league API, surprised the big sites like Gosugamers and Joindota haven't implemented it into their ticker yet.
    // Economy
    "NotTheStringsYoureLookingFor"

  9. #9
    Basic Member adrianlegg's Avatar
    Join Date
    Mar 2012
    Posts
    568
    What can we do with team_id in:

    "radiant_team":
    {
    "team_name": "Absolute Legends Academy",
    "team_id": 231312,
    "complete": false
    },
    "dire_team":
    {
    "team_name": "4 Friends + Chrillee",
    "team_id": 41,
    "complete": false
    },
    Is there some Team API to list current players/get id (to use with getugc...) of team logo, basing on team_id?
    You gotta FIGHT!
    For Your RIGHT!
    To BUUUGFIX!

  10. #10
    Administrator
    Join Date
    Oct 2012
    Posts
    66
    There's no GetTeam API (yet), but specifically team_logo should be present in the response to GetLiveLeagueGames when the next server patch goes live.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •