Announcement

Collapse

Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.



In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.



All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

Another way for API processing with PHP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • lodagema
    replied
    Just wanted to say that I love this wrapper. I'm rather new to PHP and poring over this has really given me some more insight into how to code OOP PHP. I am making my own wrapper for dota 2 (only for personal use), using your wrapper as a "how to" guide. Hope this is ok with you? I will of course site/give reference to your original code

    Thank you again for making this!!

    Leave a comment:


  • SoloMidPlz
    replied
    what about series id and series type

    Leave a comment:


  • MuppetMaster42
    replied
    the parent id in the child object is a problem when you're converting the object to json for use in a rest api!
    well it's not exactly a problem as much as it's very inefficent in that case

    yeah i didn't think of it like that re the matches/match mappers.

    Leave a comment:


  • GelioS
    replied
    MuppetMaster42, thanks for you response!
    Both json files are already fixed.
    About mappers:
    match_mapper_db gets whole info about one match and does requests for tables - matches, slots, additional units, ability_upgrades and picks_bans (if CM). One request for each table.
    matches_mapper_db gets info about several matches. It is written to do minimum requests to the db. It also does one request per slots, additional_units, ability_upgrades and picks_bans.
    If I try to use match_mapper_db in the matches_mapper_db, I'll have much more requests - 5 * count of matches.
    And about slot_id in the nested arrays - well, its not a big problem that child-element has key of his parent IMHO

    Leave a comment:


  • MuppetMaster42
    replied
    in your heroes.json file, you have incorrectly labelled necrophos and windranger,
    their in game code namesa are still necrolyte and windrunner, it's just their localized_name that changed

    i.e.. it is
    Code:
            {
                "name": "windranger",
                "id": 21,
                "localized_name": "Windranger"
            },
            {
                "name": "necrophos",
                "id": 36,
                "localized_name": "Necrophos"
            },
    but should be
    Code:
            {
                "name": "windrunner",
                "id": 21,
                "localized_name": "Windranger"
            },
            {
                "name": "necrolyte",
                "id": 36,
                "localized_name": "Necrophos"
            },

    Leave a comment:


  • MuppetMaster42
    replied
    I noticed that in your abilities.json file you have two abilities that have been accidentally duplicated:
    Code:
            {
                "name": "luna_lucent_beam",
                "id": "5222"
            },
    and
    Code:
            {
                "name": "pudge_dismember",
                "id": "5077"
            },
    Last edited by MuppetMaster42; 02-18-2014, 06:55 AM.

    Leave a comment:


  • MuppetMaster42
    replied
    I've finally gotten back into doing my dota site (it only took me a year...)

    two changes I'd like to suggest:
    1)
    in your matches_mapper_db I notice that you load all of the match data and piece together the match objects.
    but you already do this in match_mapper_db. It seems silly to have duplicate code - it'd be smarter to use your match_mapper_db->load method inside matches_mapper_db->load method so that you only have one set of match-loading code.

    2)
    in match_mapper_db when you are loading all of the ability and additional_unit data, i notice that you don't prune out the slot_id data from each of these entries, which means that every single element in each of those arrays has an identical slot_id element.. which is useless considering it's nested within the slot itself by then..

    suggested change:
    the ability code starting from line 59 in the old code:
    Code:
            foreach($ability_upgrade as $a) {
                if (!isset($ability_upgrade_formatted[$a['slot_id']])) {
                    $ability_upgrade_formatted[$a['slot_id']] = array();
                }
                $a_clone = $a;
                unset($a_clone['slot_id']);
                array_push($ability_upgrade_formatted[$a['slot_id']], $a_clone);
            }
    and the additional unit code from line 68 in the old code:
    Code:
            foreach($additional_units as $additional_unit) {
                if (!isset($additional_units_formatted[$additional_unit['slot_id']])) {
                    $additional_units_formatted[$additional_unit['slot_id']] = array();
                }
                $additional_unit_clone = $additional_unit;
                unset($additional_unit_clone['slot_id']);
                array_push($additional_units_formatted[$additional_unit['slot_id']], $additional_unit_clone);
            }
    all that those changes are doing is cloning then unsetting the slot_id field in the arrays before adding them to the slot.

    Leave a comment:


  • Frode
    replied
    Originally posted by GelioS View Post
    Frode, pls show the folders structure (where is api folder, where is config.php and where is file that includes config.php).
    About pdo_mysql.default_socket, I didn't put nothing there.
    well I have a php code snippet plugin for Wordpress, to run the code on my WP pages. The structure is:
    /data
    /images
    /includes
    config.php

    The file that runs the code is in this folder, called insert_php.php.

    Leave a comment:


  • GelioS
    replied
    Frode, pls show the folders structure (where is api folder, where is config.php and where is file that includes config.php).
    About pdo_mysql.default_socket, I didn't put nothing there.

    Leave a comment:


  • Frode
    replied
    So I got the query to work. Though it appears that it wont "find" the included folders (mappers etc). Is the config file broken? The part about it trying to find the required class and folder. It doesn't.

    Also, side question: "pdo_mysql.default_socket=" What should the socket be?

    Leave a comment:


  • Frode
    replied
    Originally posted by GelioS View Post
    Frode, I tried to run db_latest.sql few minutes ago and didn't get any error.
    Did you modify sql-queries from file?
    Thank you for your response. Okay. I added the WP DB details (db_user/db_pass/db_host/db_name) in config.php and tried to run the query from phpmyadmin after uploading the files to my site. I have PHP 5.3 (Mysql 5.5) supported on server, with PDO_mysql and cURL enabled in php.ini. So I can't see why it wouldn't let me run the queries. (URL: http://www.worldofdota2.com/)

    Leave a comment:


  • GelioS
    replied
    Frode, I tried to run db_latest.sql few minutes ago and didn't get any error.
    Did you modify sql-queries from file?

    Leave a comment:


  • Frode
    replied
    Originally posted by Frode View Post
    I've uploaded the files from github to my server (root), added API and db details in config.php, and now trying to run the SQL query. However I get the following error:
    #1005 - Can't create table 'dota2wp.ability_upgrades' (errno: 150) How come?
    Anybody?

    Leave a comment:


  • Frode
    replied
    I've uploaded the files from github to my server (root), added API and db details in config.php, and now trying to run the SQL query. However I get the following error:
    #1005 - Can't create table 'dota2wp.ability_upgrades' (errno: 150) How come?
    Last edited by Frode; 02-10-2014, 04:10 AM.

    Leave a comment:


  • GelioS
    replied
    Phoenix and Terrorblade are already in jsons (with their abilities) - click.

    Leave a comment:

Working...
X