SearchQuery() doesn't run (undefined method PHRETS\Session::SearchQuery()) - php

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.

Related

How does the Google Service Client (PHP) method documentation work?

I have consistent difficulty using any client service method that is not explicitly exampled somewhere. Despite following the docs and even reading the sourcecode, The class or method names I come up with following the scheme are never right.
The documentation at Packagist (see 'Making Requests") says the client library classes are autogenerated from the Google endpoints, which agrees with the description in the library's docs on Github that say the pattern for accessing methods should be "$service->resource->method(args)".
So why the following?
// works:
// I get a countable object of active classrooms owner by the specified id
$response = $this->ClassroomService->courses->listCourses([
'courseStates' => 'ACTIVE',
'teacherId' => 'me']);
// works:
// I get an instance of the single classroom's object containing lots of meta data
$response = $this->ClassroomService->courses->get( $id );
// does not work:
// 500 error, obj has no such method
$response = $this->ClassroomService->topics->listCoursesTopics( $id );
According to the API Explorer all three should be fine.
What am I missing about using client service objects?
Edit
Ultimately I determined the resource in my example to be 'courses_topics'; the method was correct per the docs. Thanks for the idea #ebram.
The question remains how the methods are named though. courseWork is my next challenge and it does not fit the the naming pattern of topics.
There is no topics member of ClassroomService.
The member is named courses_topics.
This is documented in the "Properties summary" at the bottom of the Classroom documentation.
Your code should look like this:
$response = $this->ClassroomService->courses_topics->listCoursesTopics( $id );
The documentation for Google_Service_Classroom_CoursesTopics_Resource does incorrectly give sample code where the member is named ->topics.
Given that API documentation is generated from source, but sample code is (generally) written by hand, I'll assume the API documentation is correct and the sample code is incorrect. I'd file a documentation-bug with Google.
Update:
I looked at the PHP source code for Google_Service_Classroom in GitHub and verified that the property is named courses_topics instead of topics, so in conclusion: the sample code is wrong.
What's also interesting is the resource-type in the actual source-code is Google_Service_Classroom_Resource_CoursesTopics but the documentation refers to it as Google_Service_Classroom_CoursesTopics_Resource - so that documentation is definitely wrong.

PHP-FFMpeg prerequisites

I'm attempting to implement https://github.com/PHP-FFMpeg/PHP-FFMpeg
I copied the src/FFMpeg folder to my includes folder and made sure my autoloader knows where to find everything.
as a test I made a script that simply does:
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('video.mpg');
I get:
Fatal error: Class 'Doctrine\Common\Cache\ArrayCache' not found in /var/www/php/include/FFMpeg/FFProbe.php on line 203
My question is: does PHP-FFMPeg require Doctrine, because that is not stated in the documentation. What version do I need? Are there other prerequisites?
I could create a new question for this, but I'm not sure if I should. I now have PHP-ffmpeg implemented. I'm using Laravel, however that should be irrelevant for this question. I'm trying to enable progress monitoring. It works, however I need to pass in an ID so I can update the correct key in memcache.
$id = 12345;
$format->on('progress', function ($audio, $format, $percentage) {
//this works perfect, but doesn't tell me which item is being updated
Cache::put("progress", $percentage, .25);
//this does not work as I am unable to pass in $id, if I add it as the 4th argument above it will display the number of threads or something
//Cache::put("{$id}_progress", $percentage, .25);
});
I need clarification on the "on" method. I looked through https://ffmpeg-php.readthedocs.org/en/latest/_static/API/ and was not able to figure out how this method works. Any help would be appreciated.
You should follow the recommended instructions in the README.
Composer is the easiest way to install PHP-FFMpeg dependencies
The "on" method called on the format is an implementation of EventEmitter.
As you can see here : https://ffmpeg-php.readthedocs.org/en/latest/_static/API/FFMpeg/Format/ProgressableInterface.html it extends the EventEmitterInterface of https://github.com/igorw/evenement.
If you're really interested about how it works under the hood, have a look at here :
The progress listener is created here : https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Format/Audio/DefaultAudio.php#L96 and added at execution here https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Media/Video.php#L151
This is actually possible because FFMpegDriver extends the Driver provided by https://github.com/alchemy-fr/BinaryDriver
Hope this helps :)

Get requested service in Restler iAuthenticate implementation

I'm using Restler to develop a REST api and I need to get the requested service from the iAuthenticate implementation.
So far I have managed to get here:
$m = preg_match('/.+?\/(?P<api>.+?)\/(?P<service>\w+)/', $_SERVER['REQUEST_URI']);
and $_SERVER['REQUEST_URI'] has this form: /somedir/apiclass/requestedservice?...
I've tried my regex here: http://www.spaweditor.com/scripts/regex/index.php with my actual uri
and it works perfectly. When I try to parse the request url inside my iAuthenticate implementation it just don't work.
Does anybody know how to enable regex within restler iAuthenticate implementation? How can I display errors in Restler instead of a blank page?
Thanks!
[EDIT]
I wasn't passing the variable to store the match object, preg_match recieves a third argument to store it and just returns a boolean. Case closed.
I finally solved it like this:
preg_match('/.+?\/(?P<api>.+?)\/(?P<service>\w+)/', $_SERVER['REQUEST_URI'], $mo);
$api = $mo['api'];
$service = $mo['service'];

How to connect to Drupal 6 with xml-rpc

I'm trying to connect my app with Drupal. It return me this error: "Something went wrong - -32602 : Server error. Wrong number of method parameters.". I think it should work.
Have anyone any clue what is wrong here?
My code:
set_time_limit(0);
require_once("IXR_Library.php");
// Create the client object
$client = new IXR_Client('http://localhost/drupal6/xmlrpc.php');
//$client->debug=true;
$username = "admin";
$password = "admin";
$params = array(0,$username,$password,10);
if (!$client->query('metaWeblog.getRecentPosts', $params)) {
die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}
$myresponse = $client->getResponse();
You are getting an error message (Specification for Fault Code Interoperability, version 20010516) from the XMLRPC endpoint you're communicating with.
It is a defined error code:
-32602 ---> server error. invalid method parameters
The RPC method you requested was found by the server but you passed invalid parameters to it. Contact the support of the service you consume to get a list of all available methods. If your parameters should be available, contact the support and discuss the issue with them.
In your case, double-check what the Drupal manual tells you about the metaWeblog.getRecentPosts XMLRPC Method blogapi_xmlrpcDrupal API:
array(
'metaWeblog.getRecentPosts',
'blogapi_metaweblog_get_recent_posts',
array('array', 'string', 'string', 'string', 'int'),
t('Returns a list of the most recent posts in the system.'),
),
If this insufficient documentation, look the missing pieces up from within the source-code of Drupal.
For example the first parameter needs to be a string but you use the integer number 0 here.
For more information how you can make use of XMLRPC Introspection please see a releated question / answer: XMLRPC showing -32601 error (using PHP).
I do not know if drupal supports XMLRPC Introspection, but it looks like it does.

CodeIgniter Twitter API (Elliot Haughin's) capturing any URL get parameters with "oauth_token" in it

Seems a little strange.
I am using CodeIgniter with Elliot Haughin's Twitter library. It's an excellent API by the way.
However, I autoload this library in "autoload.php" in the config folder and I noticed ANY URL that has "oauth_token" URL parameter is captured by this library.
For example, when I type
http://localhost/myapp/index.php/controller?oauth_token=1
Then it throws up an error
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: libraries/Tweet.php
Line Number: 205
I went through the library and found that the following constructor calling a method that checks the GET parameters.
class tweetOauth extends tweetConnection {
function __construct()
{
parent::__construct();
..
..
..
$this->_checkLogin();
}
and the method "_checkLogin()" does the following
private function _checkLogin()
{
if ( isset($_GET['oauth_token']) )
{
$this->_setAccessKey($_GET['oauth_token']);
$token = $this->_getAccessToken();
$token = $token->_result;
...
...
What would be the best way to fix this?
Why do you have oauth_token in the querystring if you're not checking for a valid oauth_token?
I'm assuming at some point you want to state that a oauth_token has been set and you're just using oauth_token=1 as the parameter?
The library is set to always test against oauth_token, and it's not really a feasible tweak to do it any other way if you're autoloading it. You'd need a whitelist/blacklist of controllers (and maybe methods) it runs on, which pretty much defeats the point of autoloading.
If REALLY need to use oauth_token=1, you could just change it to
if ( isset($_GET['oauth_token']) && $_GET['oauth_token']!==1)
If you were using more than one value for oauth_token (or if your worry is that you can trigger an error by appending oauth_token=X to a URL) you could try and use a regex instead, assuming that all oauth_tokens follow a pattern (32 characters long etc).
Alternatively you could also probably just exit/return false depending on what is returned in $token = $this->_getAccessToken(). Depends what happens elsewhere in the code. Looks like returning false should just work.

Categories