Calling API's in my site.

Hi, I am really new with API’s and I need it to show up and work in my site… But my site is running in a forum software and I know just a little about php and zero in API and how to make it global so that it will run in my forum. If I get the situation right.

I found these codes and have them all installed in my system, unfortunately, it won’t show up anywhere in my site.

I want to display match results in my site, for example, I created a thread.

Thanks in advance.

Maybe this is the start of my learning PHP. I’ve studied a little of it but running in another system is a different story.

an api is just a collection of code released by a group in order to make writing code that interacts with their’s easier for us. the readme.md in the collection you linked to seems to have all of the information needed to get this up an running, could you be a little more specific about what you have tried so far?

did you edit the config file as it says, did you place the code ANYWHERE or just copy the files? did you create your database as requested by the readme?

Yes, I have done that (config and db).

Here is my website (i cannot post any urls) pinoydoto.com

I have tried creating a page WITHIN my forum and it didn’t display anything. I have tried this reading this (http://dev.dota2.com/showthread.php?t=58317) thread. And inserting this code in my created page within the forum. Of course I have put my key and match id correctly.

[php]<?php
$matchID = “51730xyz”;
$key = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
$baseUrl = ‘https://api.steampowered.com/IDOTA2Match_570/’;

/* Get Match Details */ 
$url[0] = $baseUrl.'GetMatchDetails/V001/?key='.$key.'&match_id='.$matchID;     
 

/* Get 25 latest matches from AM */ 
$url[1] = $baseUrl.'GetMatchHistory/V001/?format=JSON&language=en_us&key='.$key.'&hero_id=1'; 
 

/* Get list of up2date heroes */ 
$url[2] = 'https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key='.$key.'&language=en_us&format=JSON';         


for($i = 0; $i<count($url); $i++) { 
    $response = file_get_contents( $url[$i], $info);       // here happens the request to the api and the response is saved 
    if($response != null ) { 
        print_r($response);                                // print response data, its an array so for rapid coding its enough 
    } else { 
    print_r('empty response<br/>'); 
    sleep(1);                                              // to stay in the limits of 1 req per sec 
    } 
} 

?>[/php]

EDIT: Thanks for your reply. :slight_smile:

on this line:
[php]$url[2] = ‘https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=’.$key.’&language=en_us&format=JSON’[/php]

try hardcoding your key, to be sure the variable is not the issue

so it should look like this:
[php]$url[2] = ‘https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=xxxxxxxxx&language=en_us&format=JSON’[/php]

It didn’t work.

What I’m trying to say is a way the site would work/look like this http://www.gosugamers.net/dota2/tournaments/2784-starladder-starseries-season-8/764-groupstage/2785-round-robin/matches/30543-alliance-vs-virtus-pro-dota2

well there is nothing wrong with the string, i got an api and tested it and it returns info. from what I can see you don’t actually include the dota-wrapper class in your page. you also don’t have your database defined as it says to.

i would suggest working directly with the steam api rather than this wrapper, at least until you have a better understanding of what you are doing.

try working with the code below to see if any of it makes sense to you:

[php]$matchID = “51730xyz”;
$key = “xxxxx”;
$baseUrl = ‘https://api.steampowered.com/IDOTA2Match_570/’;

/* Get Match Details */
$url[0] = $baseUrl.‘GetMatchDetails/V001/?key=’.$key.’&match_id=’.$matchID;

/* Get 25 latest matches from AM */
$url[1] = $baseUrl.‘GetMatchHistory/V001/?format=JSON&language=en_us&key=’.$key.’&hero_id=1’;

/* Get list of up2date heroes */
$url[2] = ‘http://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=’. $key. ‘&language=en_us&format=JSON’;

$res = file_get_contents($url[2]);
$json_output = json_decode ( $res, true );

foreach ($json_output[‘result’] as $heroes) {
foreach ($heroes as $k => $hero) {
echo ‘Hero #’. $k. ‘
’;
echo $hero[‘localized_name’]. ’ = '. $hero[‘name’]. ‘
’;
}
echo ‘
’;
}
var_dump($json_output);[/php]

Hi, I’m really thankful of your replies. I will check it later at noon as it is already midnight here and let you know.

Do you think I can make it work via creating a thread and not a page? Can you help me out?

you’re welcome :slight_smile: what forum software do you use?

How can I contact you? Do you use Skype?

I actually don’t, not very technically relevant of me huh? :wink: honestly i do this for work so i am not looking to get really in depth, but fyi whenever you respond to this topic or pm me here i get an email, so you can trust that to let me know in a timely manner…

I actually wanna let you see the backend so you can really know and test the site. I’ll make you an admin. That’s why I wanted to contact you.

you should be more careful than that. just because someone helps on a forum doesn’t mean they are a good person. I like to figure out the problem, that’s the main reason i post here. yes I like to help people but I can see how those who DON’T would still answer for the feeling you get when you figure out the problem.

that being said, and as long as you understand that anything i did look at would be COMPLETELY in my spare time, which is limited, and i’m not agreeing to do anything in particular except look at problems and help when i feel like it, then pm me and i’ll send you my email address :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service