Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: dota 2 api framework

  1. #1
    Basic Member
    Join Date
    May 2012
    Posts
    52

    dota 2 api framework

    dota-2-engine (dota 2 api framework )

    this framework based on dota 2 api (http://www.dota2wiki.com/wiki/API) and php language .
    the idea is to fetch json response and build objects , this kind of method use for hide hard part of process and make it easier to use .

    framework example for getting match details :

    PHP Code:
    $doProcess = new doProcess();
    $match $doProcess->fetchMatchDetailsById(113987391);
    if(
    $match->getRadiant_win() ) 
        {
            echo 
    '<h3>Radiant win</h3>'
        }
        else echo 
    '<h3>Dire win</h3>';
    $players =  $match->getPlayers();
    foreach(
    $players as $player)
    {
    echo 
    $player->getAccount()->getPersonaname()

    raw api use for getting match details :

    PHP Code:
    $url "https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?key=<key>&match_id=113987391";
    $jsonResponse file_get_content($url) ;
    $jsonObject json_encode(jsonResponse );
    if(
    $jsonObject ->result->radiant_win == 'true')
    {
            echo 
    '<h3>Radiant win</h3>'
    }
    else echo 
    '<h3>Dire win</h3>';
    $players $jsonObject ->result->players ;
    foreach(
    $players as $player)
    {
    $url "https://api.steampowered.com/ISteamUser/GetPlayerSummaries/V002/?key=<key>&steamids=".$player->account_id;
    $jsonResponse file_get_content($url) ;
    $jsonObject json_encode(jsonResponse );
    echo 
    $jsonObject->result->players->personaname ;

    if you go deeper it gets worse !
    but in framework every thing fine and works easy !

    full IDOTA2Match_<id> Api Support

    | **Supported**
    | GetMatchHistory
    | GetMatchDetails
    | GetPlayerSummaries
    | GetLeagueListing
    | GetHeroes
    | GetMatchHistoryBySequenceNum
    | GetTeamInfoByTeamID
    | GetLiveLeagueGames
    | GetScheduledLeagueGames



    dota2engine support multi level programming !

    you can make your own api on top of frame work for example see:

    PHP Code:
    <?php

    //test_api_maker.php or http://dota.remake.ir/test_api_maker.php

    require_once 'engine.php' ;

    // template helpers are just for giving you good implementation to build fast and better view . 
    // they are not core system just for help .
    require_once 'helpers/template/item.helper.php' 
    require_once 
    'helpers/template/position.helper.php' 

    // using analyze helper
    require_once 'helpers/analyze/analyze.helper.php' 


    $doProcess = new doProcess();
    $match $doProcess->fetchMatchDetailsById(186887325);

    if(
    $match){

    echo  
    '<h3> make api respone over framework </h3><br />' ;

    echo  
    '<h4> full match data (any thing you need of ) </h4><br />' ;     
    // full match data (any thing you need of )
    $api_maker_data JsonHandler::encodeToApi($match);
    print_r($api_maker_data) ;  
    echo 
    '<br />' 


    echo  
    '<h4> full player data dumping (any thing you need of ) </h4><br />' ;    
    // full player data dumping (any thing you need of )    
    $players =  $match->getPlayers();
    $api_maker_data JsonHandler::encodeToApi($players);
    print_r($api_maker_data) ;  
    echo 
    '<br />' ;     

    echo  
    '<h3> customize api respone over framework </h3><br />' ;


    echo  
    '<h4> helper data analyze </h4><br />' ;  

    echo  
    '<h6> best Player </h6><br />' ;  
    $bestPlayer $analyzer->analyzeBestWarrior($players) ;
    // helper data analyze
    $api_maker_data JsonHandler::encodeToApi($bestPlayer);
    print_r($api_maker_data) ;  
    echo 
    '<br />' 

    echo  
    '<h6> top 10 players </h6><br />' ;   
    $top10players $analyzer->analyzeTopTenWarriors($players) ;
    // full match data (any thing you need of )
    $api_maker_data JsonHandler::encodeToApi($top10players);
    print_r($api_maker_data) ;  
    echo 
    '<br />' 

    }
    else echo 
    'not found' 

    ?>
    the objects contain all data need for any process so only convert it to json data , use can use other api call in same way .

    the project is on github : https://github.com/roozbeh360/dota-2-engine
    Last edited by roozbeh360; 05-22-2013 at 03:32 AM.

  2. #2
    Cool : )
    (Y)

  3. #3
    Basic Member Raging's Avatar
    Join Date
    Sep 2012
    Posts
    212
    Good Job!

  4. #4
    Basic Member
    Join Date
    May 2012
    Posts
    52
    thanks ! more visitors means more update for me .

  5. #5
    Basic Member
    Join Date
    Sep 2012
    Posts
    23
    Use php 5.3 namespaces and autoloading - require_once is evil.

    and https://github.com/roozbeh360/dota-2...Hero.class.php

    Line 18 - $this->$name = $name ;
    I think sold be: $this->name = $name ;

  6. #6
    Basic Member budswarez's Avatar
    Join Date
    Sep 2011
    Location
    Brazil
    Posts
    105
    Very Coolllllll o/ tnks bro

    tested on localhost, I enabled the extensions and api change in config file, and change matchid in test.php.
    Only returned "not found"
    i need help
    Last edited by budswarez; 01-23-2013 at 08:28 AM.

  7. #7
    Basic Member
    Join Date
    May 2012
    Posts
    52
    @JohnnyAjax : thanks i fix that and put your name on that commit . it's to soon to update to php 5.3 curently worked on 5.22 and up .

    @budswarez : unfortuently the have close all api ids . so it means it will always return "not found" if you want real test you must wait until they decide to open api again .
    but there is another way ! find matchDetails or matchHistory json dump file and store it on hard drive then edit these files, like this :

    copy json files to this :

    [framework directory]fountain

    it will be like this :

    fountain\matchDetails.json
    fountain\matchHistory.json

    edit files:

    action/base/baseBootProcess.class.php
    ---------------------------------------------
    line 20 :
    $query = config::$api_url.config::$api_dota_name.'/'.config::$api .......
    to
    $query = dirname(__FILE__).'/../../../fountain/matchDetails.json';


    action / base / build / coreBootProcess.class.php
    ---------------------------------------------
    line 72 :
    $query = config::$api_url.confi ......
    to
    $query = dirname(__FILE__).'/../../../../fountain/matchHistory.json';
    Last edited by roozbeh360; 01-23-2013 at 09:46 AM.

  8. #8
    Basic Member
    Join Date
    May 2012
    Posts
    52
    looks like dota 2 api back again ! so clone latest version from git hub and good luck .

  9. #9
    Basic Member
    Join Date
    Sep 2012
    Posts
    10
    Everything works except the account information. I can access player summaries manually through the URL though.

    Im getting:
    Fatal error: Call to a member function getSteamid() on a non-object

    I'm using the example you have in the DOCS.

    Code:
    $doProcess = new doProcess();
    
     $match = $doProcess->fetchMatchDetailsById(1455138);
    
    if($match){
    
    $players = $match->getPlayers();  
    
    echo $players[9]->getAccount_id() ;
    
    echo $players[9]->getHero()->getName();
    
     $player = $players[9] ;
    
    // echo  $players[9]->getAccount()->getSteamid();
    
    echo $player->getAccount()->getSteamid();
    
    echo $player->getAccount()->getPersonaname();
    
    }

  10. #10
    Basic Member
    Join Date
    May 2012
    Posts
    52
    the account object depends on profile privacy ,get latest update from github .

    if you want still want to use this example first check if account information exist !

    if( $player->getAccount())
    {
    $player->getAccount()->getSteamid();
    }

Posting Permissions

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