$url = sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=%s&steamids=%s",
$api_key,
$steam_id);
$curl_time = microtime(1);
// Needs curl to actually be able to pull data from steam api because of the special response-behaviour.
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
@curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 5 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 3 ); #rc1: helps with page delay if steam is down
$raw_json = curl_exec( $ch );
$http_response_header = curl_getinfo( $ch );
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
$url = sprintf("http://api.steampowered.com/IPlayerService/GetSteamLevel/v0001/?key=%s&steamid=%s",
$api_key,
$steam_id);
$curl_time = microtime(1);
// Needs curl to actually be able to pull data from steam api because of the special response-behaviour.
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
@curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 5 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 2 ); #rc1: helps with page delay if steam is down
$steamlevel = curl_exec( $ch );
$http_response_header = curl_getinfo( $ch );
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
$steamlevel = json_decode($steamlevel, 1);
// Get Player Bans API
$url = sprintf("http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=%s&steamids=%s",
$api_key,
$steam_id);
$curl_time = microtime(1);
// Needs curl to actually be able to pull data from steam api because of the special response-behaviour.
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
@curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 5 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 2 ); #rc1: helps with page delay if steam is down
$tradeban = curl_exec( $ch );
$http_response_header = curl_getinfo( $ch );
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
$tradeban = json_decode($tradeban, 1);
// END Get Player Bans API
// Get Item Info API //
$url = sprintf("http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=%s&steamid=%s",
$api_key,
$steam_id);
$curl_time = microtime(1);
// Needs curl to actually be able to pull data from steam api because of the special response-behaviour.
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
@curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 5 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 2 ); #rc1: helps with page delay if steam is down
$getplayeritems = curl_exec( $ch );
$http_response_header = curl_getinfo( $ch );
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
$getplayeritems = json_decode($getplayeritems, 1);
// END Get Item Info API //Ik merk op dat door vele API's te gebruiken van steam, dat het laden van de pagina echter lang duurt. Ik probeer dit dus te combineren in 1 code, i.p.v. 4x een curl_close($ch);. Met hopelijk dat ik een optimized code kan gebruiken om de laad-tijd te verbeteren. Met PHP ben ik nog nieuw, dus ik doe mij best :).
Wie kan mij hierbij helpen? Ik heb al verschilende soorten curl's geprobeerd, maar het lukt me maar niet.