我正在开发一个由Steam驱动的图像托管网站,一切都很顺利。但我真正喜欢的一个功能是如果他们有一个Screen Shot Showcase,就可以从他们的Steam配置文件中获取用户Screen Shot Showcase。我仍然是php和api的新手,但我知道我的方式我只是不知道正确的设置。这是我基于它的代码。
function grabScreenData() {
global $DB;
if($this->isLoggedin()) {
// Grab the info from the session
$userData = $DB->getUserById($_SESSION['steam']);
if(isset($userData['steamid'])) {
$this->user = $userData;
} else {
unset($_SESSION['steam']);
die('Could not get user');
}
} elseif(isset($_SESSION['loginid'])) {
$url = 'http://api.steampowered.com/ISteamRemoteStorage/GetUGCFileDetails/v1/?key='.$this->api.'&steamids='.$_SESSION['loginid']'&appid=440''&ugcid=280174773';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
curl_close($ch);
$content = json_decode($content, true);
$_SESSION['steam'] = $_SESSION['loginid'];
// Set the database values
$values = array(
'steamid' => $content['data']['status'][0]['steamid'],
'filename' => $content['data']['status'][0]['filename'],
'url' => $content['data']['status'][0]['url'],
'size' => $content['data']['status'][0]['size'],
);
// Are updating the user info or adding them?
$userExists = $DB->getUserById($uid);
if(isset($userExists['steamid'])) {
// We have this user, lets update their info
$DB->update('screenshots', $values, array('steamid' => $_SESSION['steam']));
} else {
// New user, lets insert them
$id = $DB->insert('screenshots', $values);
}
unset($_SESSION['loginid']);
$this->grabScreenData();
}
}
此功能的用途是获取此数据GetUGCFileDetails
如果有人愿意帮助我,我会更有可能设置api通话错误我真的很感激它,因为它让我疯狂大声笑。我使用相同的调用函数来获取用户数据,它只是改变了一些东西。也许有人在这里了解php,curl和api数据抓取:)。