sparkapi / sparkapi4p2 Goto Github PK
View Code? Open in Web Editor NEWA PHP wrapper for the flexmls REST API.
License: GNU General Public License v3.0
A PHP wrapper for the flexmls REST API.
License: GNU General Public License v3.0
minor issue but the Core file throws
Deprecated: Call-time pass-by-reference has been deprecated in Core.php on line 240
Good morning. I upgraded the PHP version from v7.2 to v7.4 on our VPS a few weeks ago, and I noticed that the client library doesn't work with that version. I had to revert back to v7.2 in order to get everything working again.
Are there any plans to get this client library upgraded to work with PHP version 7.4 any time soon? Or has it recently updated to support it, by any chance?
Thanks,
-- Yvan
Hi There,
Can you tell me how do we get non-expiring access token. Please explain or provide a documentation link for obtaining non-expiring access token through authorization.
In Core.php on line #150:
$time = substr($val, 0, -1);
actually removes last character from the $val variable and then the wrong value is returned in the condition below where $time = $val:
if (empty($time)) {
// no trailing identifier given so assuming that what was given was in seconds
$time = $val;
}
So, if I pass 10800 seconds (3 hours) to the method, I get 1080 back, which is only about 18 minutes.
using the mysql cache function in the new api, and it seems that we need to alter it so that a "null" response is not cached-- an initial request for properties in our system returns NULL, and it appears that all subsequent requests for this data end up as null.
here's the request params:
array
'_expand' => string 'PrimaryPhoto' (length=12)
'_limit' => int 10
'_filter' => string '' (length=0)
'_pagination' => boolean true
'_page' => int 1
'_orderby' => string '-ListPrice' (length=10)
in the sparkAPI4p2, you accept an optional parameters object with this method:
GetAccountsByOffice($id, $params = array())
However, in the actual platform docs (http://sparkplatform.com/docs/api_services/my_account#RetrieveAccountInfoForAnOffice) it says that there are no params.
I'd like to use the params object to filter the accounts (to search for agent by name, for example) or to order by. But I don't think this is supported in the API.
This file: https://github.com/sparkapi/sparkapi4p2/blob/master/examples.php have an error:
Line 18:
$api = new SparkAPI_SparkAPI_Bearer("your_access_token_here");
Correct version:
$api = new SparkAPI_Bearer("your_access_token_here");
Having required parameters after optional parameters was deprecated in php8
and now in php 8.0.8 trhows an error
ErrorException
Required parameter $default follows optional parameter $options
Line 848 in 2b92255
Good afternoon. I've been experimenting with the GetListingPhotos() method within the client library, It's apparent that it needs to be seeded with the listing ID number in order for it to work,, .. but I was wondering .. would it be at all possible to retrieve the photos by seeding using the MLS number .. instead of the Listing ID number? If so, .. how? And could it be done without having to query the API twice in a row? (first time = to retreive the listing id number -- PLUS -- second time to retrieve the photos).
Please advise.
Thanks!
-- Yvan
I've been using "'_expand' => 'Photos'" with the GetListing() method, and everything has been working fine. However, I'm now trying to also retrieve Listing Documents (in addition to the Photos), and and am attempting to do so using "'_expand' => 'Photos, Documents'", but Documents it's returning an empty array. Can I specify multiple values when assigning the "_expand" parameter? If so, then what is the correct syntax for retrieving both Photos and Documents?
Thanks,
-- Yvan
Good afternoon. I see in the examples that it's possible for us to enable the caching of the Spark API data in a WordPress database. I just have 2 quick questions regarding that.
Do I first need to manually create the "api_cache" table in the MySQL database? Or does the enabling of the WordPress cache create that table for me automatically?
How frequently does the WordPress cache get flushed and then repopulated? And is there a way that the flushing and repopulating of the cache can be forced or automated? If so, how?
Thanks,
-- Yvan
Here is the error message I recieved.
Uncaught Error: Call to undefined method SparkAPI_Bearer::ReAuthenticate()
Could you also provide a basic example of obtaining access token using "OpenID Connect Authentication" using the latest version.
Any help would be highly appreciated.
Hi there,
I tried to use the GetMarketStats method to get the market stats but I can't make it work. Could you please help me.
Thanks a lot!
I'm noticing that when using the GetListings() method, and when attempting to assign a "_pagination" value of "1", .. that I am not getting the expected Pagination section in the result:
"Pagination": {
"TotalRows": 78,
"PageSize": 25,
"TotalPages": 4,
"CurrentPage": 1
}
Here is my code snippet:
$resultAll = $api->GetListings(
array(
'_pagination' => 1,
'_filter' => "PropertyType eq 'A' and (MlsStatus eq 'Active' or MlsStatus eq 'Pending'')",
'_limit' => 25,
'_expand' => 'PrimaryPhoto'
)
);
print_r($resultAll);
Obviously this presents a problem, as I have no way of knowing how to set up my pagination, as I have no "TotalRows" value available to me that I can apply some simple math to. Note that I also tried specifying a _pagination value of "count" .. (both with surrounding quotes and without) but that just returns an empty array.
Lastly, note that when I specify these same queries using Postman, .. I do get the expected Pagination section in the result. It just doesn't appear to be working with the PHP client library.
Is there some vital piece that I'm missing, perhaps? If so, how do I return the TotalRows value? Or is not technially possible to retrieve this information using the PHP client library?
Thanks,
-- Yvan
When running the following code, it will return the following error (vague, I know).
$resultGetListings = $api-> GetListings(array("_filter" => "ListingKey Eq 'enter key here'", "_pagination" => "count"));
PHP Notice: Undefined index: Results in /var/www/Core.php on line 312
Hi there,
I'm Joseph B. web developer, I developed a web apps using the this php sdk(sparkapi). I was very happy to the result, I got what I want however there's an issue I encountered that I cannot able to fix. I encountered error code 1550 which is over rate limit, I debugged my codes and I found out that every time I make a request to flex it's also requesting a new access token which is not supposed to be. I checked the database and I noticed every time I make a request the SparkAPI_authtoken value was changing which is not suppose to be I think? I was wondering if this issue is related to SDK itself or just in my codes. For more info I posted my codes and my email I've send to flex support below.
For your reference
Here's my last email to flex support
Hi Don,
Thank you very much for your help. I almost got your point but I need few more clarification.
For your information here's what my codes does. I created a main controller class and a listings class, the listings class extends to main controller class. Inside the main controller class I have the flex_connect function this function will do the api auth connection and I call this functions every time the listings class was initiated and I think this was causing the over limit of authentication request.
In every search query the listings class was called and of course the flex_connect method too because it was placed in the _construct method of listings class. I was wondering though if there's a way to check the last session created and used it instead of requesting a new one? Please advice, I want know if the PHP SDK you've provided has this already if they don't have I have no choice to one.
MAIN CONTROLLER CLASS
class main_controller_class{
function flex_connect(){
$api = new SparkAPI_APIAuth($this->api_key, $this->api_secret);
$api->SetApplicationName("PHP-API-Code-Examples/1.0");
$api->SetCache( new SparkAPI_MySQLiCache($this->db_host, $this->db_name, $this->db_user, $this->db_pass, 'api_cache'));
$result = $api->Authenticate();
if ($result === false) {
echo "API Error Code: {$api->last_error_code}<br>\n";
echo "API Error Message: {$api->last_error_mess}<br>\n";
exit;
}
}
return $api;
}
LISTINGS CLASS
class listings_class extends main_controller_class{
function __construct(){
$this->api = $this->flex_connect();
}
}
Thank you in advance for your help. :)
GetCustomFields method requires property type argument, but the API doesn't support it and returns an error. Works correctly without the argument.
By the way, GetStandardFields() and GetCustomFields() should probably return first result instead of all results.
Thanks!
Good morning. I'm noticing that I am unable to retrieve and display more than 50 listings in a single query (using the $api->GetListings() method). I've been leveraging the useful "_pagination", "_limit" and "_page" parameters extensively in my project, and can understand why there would be certain limits in place. But I've run into a situation where I need to retrieve 200+ listings from the API in a single request and then store them in a database, and I see no apparent way to do that. Is there any way at all that this can be accomplished? If so, how?
Here is my current query with the pagination specific parameters still in place:
$mlsdata = $api->GetListings( array( '_select' => "ListingId, ListAgentMlsId, BuyerAgentMlsId, PrimaryPhoto, UnparsedFirstLineAddress, BathroomsTotalDecimal, BedsTotal, BuildingAreaTotal, YearBuilt, PropertyType, CloseDate, ClosePrice", **'_pagination' => 1,** '_filter' => "(MLSAreaMinor eq '4190') and (PropertyType eq 'A' or PropertyType eq 'C') and (MlsStatus eq 'Closed') and (CloseDate gt $twoyearsago) and (ClosePrice gt 700000)", _'_limit' => $perpagelimit,_ _'_page' => $pagenumber,_ '_expand' => 'PrimaryPhoto', '_orderby' => '-CloseDate' ) );
Also -- on a related note -- I'm noticing that when I change '_expand' => 'PrimaryPhoto' to ''_expand' => 'PrimaryPhoto, CustomFieldsExpanded'' .. the query for some reason fails and returns 0 records. Why is that? Is it not possible to expand "CustomFieldsExpanded" with queries that return more than one listing?
Thanks,
-- Yvan
Noticed that the caching mechanism returns the same results for a query using the random orderby param. Would be good to either check for
$parameters['_orderby'] = 'Random';
and then bypass the cache, or perhaps allow another param to be passed in to ignore the cache.
This is a simple one, but the function GetMyAccount is missing a $params array, even though it can accept an "_expand" option.
function GetMyAccount() {
return $this->return_first_result($this->MakeAPICall("GET", "my/account", '1h'));
}
function GetMyAccount($params = array()) {
return $this->return_first_result($this->MakeAPICall("GET", "my/account", '1h', $params));
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.