Steam API屏幕截图抓取PHP

我正在开发一个由Steam驱动的图像托管网站,一切都很顺利。 但我真正喜欢的一个功能是如果他们有一个Screen Shot Showcase,就可以从他们的Steam配置文件中获取用户Screen Shot Showcase。 我仍然是php和api的新手,但我知道我的方式我只是不知道正确的设置。 这是我基于它的代码。 </ p>

  function grabScreenData(){
global $ DB;
if($ this-&gt; isLoggedin()){
//从会话中抓取信息
$ userData = $ DB-&gt; getUserById($ _ SESSION ['steam']);
if(isset($ userData ['steamid'])){
$ this-&gt; user = $ userData;
} else {

unset($ _ SESSION ['steam']);
die('无法获取用户');
}
} elseif(isset($ _ SESSION ['loginid'])){
$ url ='http ?://api.steampowered.com/ISteamRemoteStorage/GetUGCFileDetails/v1/键=;&安培; steamids = '[登录ID '] '&安培;的appid = 440' '和' $这 - &GT API。' $ _ SESSION。' ; ugcid = 280174773';
$ ch = curl_init();
curl_setopt($ ch,CURLOPT_URL,$ url);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
$ content = curl_exec($ ch); \ ncurl_close($ ch);
$ content = json_decode($ content,true);
$ _SESSION ['steam'] = $ _SESSION ['loginid'];
//设置数据库值
$ values = array(
'steamid'=&gt; $ content ['data'] ['status'] [0] ['steamid'],
'filename'=&gt; $ content ['data'] ['status' ] [0] ['filename'],
'url'=&gt; $ content ['data'] ['status'] [0] ['url'],
'size'=&gt; $ content ['data'] ['status'] [0] ['size'],
);
//正在更新用户信息或添加用户信息?
$ userExists = $ DB-&gt; getUserById( $ uid);
if(isset($ userExists ['steamid'])){
//我们有这个用户,让我们更新他们的信息
$ DB-&gt; update('screenshots',$ values,array( 'steamid'=&gt; $ _SESSION ['steam']));
} else {
//新用户,让我们插入
$ id = $ DB-&gt; insert('screenshots',$ values);
}
unset ($ _SESSION ['loginid']);
$ this-&gt; grabScreenData();
}
}
</ code> </ pre>

此函数假设为 do抓取这些数据 GetUGCFileDetails </ p>

更多然后 可能我设置了api通话错误,如果有人愿意帮助我,我会非常感激,因为它让我疯了哈哈。 我使用相同的调用函数来获取用户数据,它只是改变了一些东西。 也许有人在这里了解php,curl和api数据抓取:)。</ p>
</ div>

展开原文

原文

I am working on a image hosting site powered by steam everything is going pretty smooth. But one feature I would really like is getting users Screen Shot Showcase from their steam profile if they have a Screen Shot Showcase. I am still pretty new to php and api but I know my way around I just do not know the right setups. This is the code I am basing it off from.

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();
}
}

What this function is suppose to do is grab this data GetUGCFileDetails

More then likely I setup the api call wrong if anyone would be kind enough to help me out I would really appreciate it because it is driving me nuts lol. I use the same call function to grab user data and it works just changed stuff around. Maybe someone on here is knowledgeable about php,curl and api data grabbing :).

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问