我正在尝试从 Steam 服务获取我的项目列表。我有两个功能,其中1个:从Steam商店接收所有物品,2个函数接收物品的价格,名称,图片。因此,当我尝试解析数据时,在我的一个帐户中,我收到一个错误:,而在我的第二个帐户中,所有解析都很好。Undefined property: stdClass::$Unblinking Eternity
var_dump($items); exit;给我看:
object(stdClass)#547 (34183) { ["Orb of Deliverance"]=> object(stdClass)#546 (2)
{ ["price"]=> float(58.31) ["appid"]=> string(3) "570" } ["Planks of the Bogatyr"]=> object(stdClass)#54.......
和一些日志:
at HandleExceptions->handleError('8', 'Undefined property: stdClass::$Unblinking Eternity', '/var/app/Http/Controllers/InventoryController.php', '320', array('market_hash_name' => 'Unblinking Eternity', 'json' => '{"Orb of Deliverance":{"price":57.780000000000001,"appid":"570","count":427,"bprice":51.490000000000002,"bcount":11663},"Planks of the Bogatyr":{"price":0.14000000000000001,"appid":"570","count":922,"bprice":0.12,"bcount":859},"Headdress of the Ember Crane":{"price":0.16,"appid":"570","count":808,"bprice":0.14999999999999999,"bcount":218},"Sash of Divine Ascension":
错误显示在320行,320行它:if($items->$item_name == 'undefined'){
我的2个功能:
public static function getItemPrice($market_hash_name) {
try {
if(\Cache::has('prices')){
$json = \Cache::get('prices');
$items = json_decode($json);
$item_name = $market_hash_name;
if($items->$item_name == 'undefined'){
return false;
} else{
return $items->$item_name->price;
}
} else {
return false;
}
} catch(Exception $e){
return false;
}
}
我如何理解,一个问题。stdClass
我的错误在哪里?我该如何修复此错误?
杨__羊羊
天涯尽头无女友
随时随地看视频慕课网APP