Multiple pages found for AppID. Which did you request?
"; + for ($i = 0; $i < count( $results ); ++$i) + { + print ""; + next( $results ); + } + } + ?> +From 26d6070d0a52bdd5d52da7faabdbd2b5eb190071 Mon Sep 17 00:00:00 2001 From: Aemony <10578344+Aemony@users.noreply.github.com> Date: Fri, 19 Nov 2021 15:40:33 +0100 Subject: [PATCH 1/2] Added initial test of Cargo based querying --- appid_cargo.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 appid_cargo.php diff --git a/appid_cargo.php b/appid_cargo.php new file mode 100644 index 0000000..3548055 --- /dev/null +++ b/appid_cargo.php @@ -0,0 +1,124 @@ + 'https://pcgamingwiki.com/w/api.php?action=askargs&conditions=Steam%20AppID::%APPID%&format=json', + 'api_pcgw' => 'https://www.pcgamingwiki.com/w/api.php?action=cargoquery&tables=Infobox_game&fields=_pageName%3DPage&where=Steam_AppID%20HOLDS%20%27%APPID%%27&format=json', + 'api_steam' => 'https://store.steampowered.com/api/appdetails/?appids=%APPID%&filters=basic', +); + +if ( !isset( $_GET['appid'] ) || $_GET['appid'] == "" ) +{ + die( "Error: No appid provided." ); +} +else +{ + $appid = $_GET['appid']; + + // Construct api_url for appid + $url = str_replace( '%APPID%', $appid, $config['api_pcgw'] ); + + // Fetch data + $hcurl = curl_init( $url ); + curl_setopt( $hcurl, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt( $hcurl, CURLOPT_TIMEOUT, 5 ); + curl_setopt( $hcurl, CURLOPT_CONNECTTIMEOUT, 5 ); + curl_setopt( $hcurl, CURLOPT_RESOLVE, array("pcgamingwiki.com:8080:127.0.0.1") ); + + $data = curl_exec( $hcurl ); + curl_close( $hcurl ); + + // Read data as JSON + $json = json_decode( $data, true ); + if ( !$json ) + { + die( "Error: Received invalid data from MediaWiki. " ); + } + + $results = $json['cargoquery']; + + // Get first results url + $first_result = reset( $results ); + $article_url = urlencode( $first_result['title']['Page'] ); +} + +if ( count( $results ) == 1 ) +{ + // Redirect + header( 'Location: ' . 'https://www.pcgamingwiki.com/wiki/' . $article_url ); + die(); +} +?> + + +
+Multiple pages found for AppID. Which did you request?
"; + for ($i = 0; $i < count( $results ); ++$i) + { + print ""; + next( $results ); + } + } + ?> +Prefer to go back? Click here.
+No page for ' . $results['name'] . ' exists, would you like to create it?
'; - print ''; + print ''; } else {