我設法創建了一個帶有itemID和Item類型的mysql數據庫。到目前爲止,我所能做的就是生成一個按鈕,打開一個網址,以便抓住前夕中央的價格。我目前無法發佈圖片。Eve API xml到php
然後php代碼會生成一個api url來顯示最終我的計劃是抓住最大買入價格和最小賣出價格的價格,並對它們執行以下操作: 如果公司需要它的項目(maxbuyprice + Minsellprice)/ 2 如果CORP不需要的項目計算爲((maxbuyprice + Minsellprice)/ 2)* 0.9
我的問題就是如何讓PHP的解析XML,而不是顯示XML文檔 - 我這樣做是爲了調試或查看可用的數據。
爲例,我與Veldspar生成的URL是: generated url using Veldspar is the item name
index.php文件:
<?php
include_once $_SERVER['DOCUMENT_ROOT'] .'/includes/db.inc.php';
$pagetitle = 'HoMs Asset Management System - Create Contract';
$pagedescription = 'HoMs Asset Management System for managing Corporation Contracts and Pricing';
include_once $_SERVER['DOCUMENT_ROOT'] .'/includes/access.inc.php';
include_once $_SERVER['DOCUMENT_ROOT'] .'/includes/ObjectClasses.inc.php';
include_once $_SERVER['DOCUMENT_ROOT'] .'/includes/helpers.inc.php';
include_once $_SERVER['DOCUMENT_ROOT'] .'/includes/EveCentral.inc.php';
if (isset($_POST['action']) and $_POST['action']=='View Eve Central Prices')
{
$itemname = html($_POST['ItemName']);
calculateAskingPrice($itemname);
}
include 'createcontract.html.php';
?>
db.inc.php文件:
<?php
//local dbstrings
//production dbstrings
$dbhost='localhost';
$dbusername='homedata1';
$dbpassword='EzPKfmxcTKAeSnDs';
$dbname='homdata';
Function connect2db()
{
Global $dbhost;
Global $pagetitle;
Global $pagedescription;
Global $mysqlport;
Global $dbname;
Global $dbusername;
Global $dbpassword;
Global $pdo;
Global $error;
Global $curNewsMessage;
Global $logged;
Global $ItemList;
try
{
$pdo = new PDO('mysql:host=' .$dbhost .';dbname=' .$dbname .';port=' .$mysqlport, $dbusername, $dbpassword);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
return TRUE;
}
catch (PDOException $dbconerr)
{
$pagetitle = 'Hom Asset Management - Database Connection Error';
$pagedescription = 'There was a problem connecting to the database';
$error = 'Unable to connect to the database server:' ."\n\n"
.'The database in which this pages content relies on is unavailable or, for other reasons is not contactable' ."\n"
.'I am liasing with my website host to get this resolved as quickly as possible. Please check later.' ."\n"
.'sorry for any inconvenience' ."\n\n" .'This information may help to diagnose the problem: <br>' .$dbconerr;
$logged = 'Sorry. The interactive areas are unavailable because the database is unavailable';
$curNewsMessage = 'News message unavailable. ' ."\n" .' Database connection error';
return FALSE;
}
return TRUE;
}
EveCentral。 inc.php文件:
<?php
include_once $_SERVER['DOCUMENT_ROOT'] .'/includes/helpers.inc.php';
function calculateAskingPrice($Item)
{
// Connect to the database and search for the item posted
include_once $_SERVER['DOCUMENT_ROOT'] .'/includes/db.inc.php';
Global $pdo;
Global $itemname;
if (connect2db())
{
$sql = "SELECT * FROM `itemtypes` WHERE ItemName=:itemname";
$s = $pdo->Prepare($sql);
$s->bindValue(':itemname',$Item);
$s->execute();
$row = $s->fetch();
if ($row > 0)
{
$itemid = html($row['ID']);
$evecurl = 'http://api.eve-central.com/api/marketstat?typeid=' .$itemid .'&usesystem=30000142';
header('Location: ' .$evecurl);
}
else
htmlout('Item not found: ' . $itemname);
}
else
{
echo 'problem connecting to database';
}
}
?>