Coder Social home page Coder Social logo

sparkapi4p2's People

Contributors

apopkin avatar calh avatar codygustafson avatar dgmyrek avatar donclem avatar fbstim avatar gsaulmon avatar joshcom avatar mflatin avatar raiman264 avatar ridley-james avatar thinkerytim avatar troydavisson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkapi4p2's Issues

deprecated

minor issue but the Core file throws

Deprecated: Call-time pass-by-reference has been deprecated in Core.php on line 240

Doesn't work with PHP v7.4 ??

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

Bug: SparkAPI_Core::parse_cache_time($val)

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.

mysql cache appears to be broken

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)

Retrieve listing photos using MLS number instead of Listing ID ?

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

Multiple values for _expand ?

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

Question about enabling WordPress cache

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.

  1. 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?

  2. 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

Unable to refresh access token automatically in version 2.

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.

_pagination parameter not returning Pagination hash / result set size

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

Error when using "_pagination" => "code" in PHP Client

When running the following code, it will return the following error (vague, I know).

Code

 $resultGetListings = $api-> GetListings(array("_filter" => "ListingKey Eq 'enter key here'", "_pagination" => "count"));

Error

 PHP Notice:  Undefined index: Results in /var/www/Core.php on line 312

Over rate limit (Error code 1550)

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. :)

Bug: SparkAPI_Core::GetCustomFields($prop_type)

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!

Retrieve and display all listings in a single query / more than 50 listings?

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

caching random orderby

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.

GetMyAccount has no $params available for "_expand"

This is a simple one, but the function GetMyAccount is missing a $params array, even though it can accept an "_expand" option.

Old Code

    function GetMyAccount() {
    return $this->return_first_result($this->MakeAPICall("GET", "my/account", '1h'));
}

New Code

    function GetMyAccount($params = array()) {
    return $this->return_first_result($this->MakeAPICall("GET", "my/account", '1h', $params));
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.