Using steam condenser with laravel 4 and installed it via composer.
I am trying to get the players inventory for dota2. I tried:
WebApi::setApiKey('*******');
$inventory = DotA2Inventory::createInventory('username');
But it gives me:
Class 'DotA2Inventory' not found
I am doing this on my User Controller.
Here is the inventory class, and here is the dota2 inventory class.
I am just trying to extract the inventory of the user so I can display it, complete with image, name, rarity and other item info.
UPDATE
So I have found that I forgot to add this:
require_once STEAM_CONDENSER_PATH . 'steam/community/GameInventory.php';
Now with that I am getting another error: Trying to get property of non-object
protected function _getJSONData($interface, $method, $version = 1, $params = null) {
$data = $this->getJSON($interface, $method, $version, $params);
$result = json_decode($data)->result;
Additional Info
I am working with version 1.3.7 of steam-condenser. (checked my steam-condenser.php to confirm this)
The error is "Trying to get property of non-object" on line 190 of WebApi.php
$result = json_decode($data)->result;
Specifically was trying to get the dota 2 inventory of the user 76561198115395760.
Having a look at the answer to this question and your issue on GitHub this may be caused by your PHP environment (WAMP) on Windows.
Please try using XAMPP (or a manual installation).
json_decode() will probably return an array. Try
$array = json_decode($data);
$result = $array['result'];
Related
My PHP app is accessing MTURK via the API and getting an Assignment object back that looks like this:
I'm trying to access the Answer field. So far I've tried:
$temp = $theResult->Answer;
$temp = $theResult->get('Answer');
...but they throw errors.
What is the correct way to access this field?
This works on my installation:
$answers = $theResult->getAnswer();
I am trying to extract some basic details from the RETS server using PHRETS but been getting this error
[*Uncaught Error: Call to undefined method PHRETS\Session::SearchQuery() in D:\Software\XAMPP\htdocs\PHRETS-master\RetsExtract.php:21 Stack trace: #0 {main} thrown in D:\Software\XAMPP\htdocs\PHRETS-master\RetsExtract.php on line 21*]
and can't seem to understand what is causing this.
So based on retsmd.com, I have Property as the resource, Listing as the class and based on these two I think I can extract the data using the SearchQuery() method.
I am relatively new to PHP and the RETS environment but here is the part of the code:
<?php
require_once("vendor/autoload.php");
$config = new \PHRETS\Configuration;
$config->setLoginUrl('http://matrixrets.crebtools.com/rets/Login.ashx');
$config->setUsername('userName');
$config->setPassword('pwdHere');
// optional. value shown below are the defaults used when not overridden
$config->setRetsVersion('1.8'); // see constants from \PHRETS\Versions\RETSVersion
$config->setUserAgent('agenUsr/1.0');
$config->setUserAgentPassword('pwdHere'); // string password, if given
$config->setHttpAuthenticationMethod('digest'); // or 'basic' if required
$config->setOption('use_post_method', false); // boolean
$config->setOption('disable_follow_location', false); // boolean
$rets = new \PHRETS\Session($config);
$bulletin = $rets->Login();
$search = $rets->SearchQuery("Property", "Listing", "(ListDate=1990-01-01+)");
?>
I am using this part of the from the GitHub repo of the PHRETS. Any idea what could be the issue here?
Thanks
This depends on the PHRETS version you are using.
Seems like you are using PHRETS library version 2.* and you referred the documentation of version 1.*
Both will work fine.
So in case anyone is looking for a solution to this, I have found a fix.
Apparently, its not SearchQuery() but just Search(). I don't know why the creator has SearchQuery() as the method in Github but Search() would show you the results that you're looking for.
How can I fetch the extension key in my post processor?
I tried it like this like suggested here
public function returnExtkey() {
return t3lib_div::camelCaseToLowerCaseUnderscored($this->extensionName);
}
However, I get:
Fatal error: Class 'MyCompany\MyExtension\PostProcess\t3lib_div' not found
I also tried to call it without the function camelCaseToLowerCaseUnderscored:
echo "EXTNAME = '".$this->extensionName."'";
But I get an empty string as result.
How can I solve this?
I suggest to ask the request object for the extension key:
$extName = $this->request->getControllerExtensionKey()
by the way: t3lib_div was replaced by \TYPO3\CMS\Core\Utility\GeneralUtility
I'm having several problems with an implementation in php for working with mongoDB
My case is that I made a function which recover an mongoDB database in $_SESSION['mongoDb'] variable, selects a collection and then use the function find($where, $fields).
My error is
Fatal error: Call to a member function find() on a non-object in...
I've tried checking mongodb php driver and others but the problem still existing...
EDIT: More info about.
Thanks for the post Eternal1, it's a bit confusing because same code is working in a production server but not my localhost XAMPP server.
For the one who ask me for the code, here you are:
public function generic_select_mongo ($collection, $fields, $where, $order, $limit)
{
$mongoBd = $_SESSION['mongoBd'];
$col = $mongoBd->$collection;
$res = $col->find($where, $fields);
$res->sort($order);
$result = array();
while ($docs = $res->getNext())
{
$result[] = $docs;
}
return $result;
}
I'm gonna investigate about Session in php. Sorry for the answer with additional info.
MongoDB connection, as other DB connections, is of resource type, which can't be serialized and therefore properly stored into session. PHP session manual states:
Some types of data can not be serialized thus stored in sessions. It
includes resource variables or objects with circular references (i.e.
objects which passes a reference to itself to another object)
PHP Sessions
I have been encountering some strange behaviour with some bits of my yii code.Let me pick out one in particular.
The code
$model = new Socialdemo;
$model = $model->findByAttributes(array('fk_recordid'=>$record_id));
$new = new Socialdemo();
$data = $model->attributes;
$data['fk_recordid'] = $new_recordid;
unset($data['id']); //unset id since we want to insert
$new->setAttributes($data, false);
$new->save();
On my local development machine is works just fine but when I deploy it on the server if brings up an error on the line of code
$data = $model->attributes;
It brings out the php error
Trying to get property of non-object
What am I missing?
Do you have the same Db data on server?
have you checked on NULL value?
$model = $model->findByAttributes(array('fk_recordid'=>$record_id));
Why are you missing the brackets after the new declaration
$model = new Socialdemo();
Also, I assume you are including a file to the Socialdemo class, is the file copied to the correct location and path correct on the server?