Skip to content
TORNLIFE More

PHP/HTML API Tutorial

Started by AAW [1525734] on in API Development.

25 replies · 739 views · thread synced · 7 days ago · View on torn.com

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

Pinder [465287]

Does anyone know how about to get top 3 items in item market? For instance the top 3 bazaars for item such as Donator pack/
Metzen [1965612]

I get the following error using your post aaw
Fatal error: Cannot use object of type stdClass as array in /home2/stats.php on line 10
Line 10 being: echo "Energy=" . $obj['energy']['current'];
Doge-Chan [1962553]

what i wanted to do AAW, was make a form where you enter your api key and have itsend over to the php "$json =file_get_contents("http://api.torn.com/user/?selections=Bars,money&key=J2fIt");"

and Metzen, it works for me on my localhost server (using xampp)

Doge-Chan [1962553]

okay, so i'm trying to get the personal stats to work while trying to only select one part from personal stats... $json =file_get_contents("http://api.torn.com/user/?selections=Bars,money,money,personalstats&key=*key is provided*");

<?php
echo "money mugged=$" . $obj->moneymugged;
?>
Meme_Raven [1891116]

This should work, haven't tested though.

<?php
$apibase = "http://api.torn.com/user/?selections=profile,basic,icons,networth,bazaar,display,personalstats&key=".$apiKey;
$response = file_get_contents($apibase);
$outputPublic = json_decode($response, true);
$userArray=Array($outputPublic["personalstats"]); $moneyMugged=number_format($userArray[0]["moneymugged"]);print_r("$".$moneyMugged);
?>