Implement getLink() on SearchResult
izziaraffaele opened this issue · 5 comments
Links are really helpful when getting large sets of items. I implemented in with this commit on my fork following your style
@izziaraffaele - unfortunately, the link would only give the next link. I've added the ability to get next and previous from the response body in 90b9991
@SocalNick Sorry for hassling you with a question about this - but i cant seem to figure this out. How do you use getNext() to actually load the next pages body of data? Rather then just give the API's Endpoint for the next page of data.
Below is my attempt at it ( hopefully that explains what I mean better) - I think I should instead be changing what $evFetchOp->getEndpoint() returns. But I'm really not sure.
Thanks
$results = [];
$i = 0;
do {
if ($i == 0) { //first run
$evFetchOp = new EventListOperation("users", $this->userID, "timeline", 100, $this->startTime, null, $this->endTime);
} else { //other runs
$evFetchOp = $evObject->getNext(); // i think i should instead be changing what $evFetchOp->getEndpoint() returns.
}
$evObject = $this->client->execute($evFetchOp);
array_merge($results, $evObject->getValue()["results"]);
$i++;
} while ($evObject->getNext());
return $results;
EDIT: I should clarify I'm referring to the events getNext() and getPrevious() for Events List
Hi,
You need to create a new EventListOperation object every time and pass it
the proper parameters you retrieve from getNext.
getNext returns you the URI of the next element. You need to explode this
URI, pull out the proper parameters, and then call your object again with
the new parameters.
I did something similar for a KvListOperation. See below:
while (($result = $this->sports->listSports(100, $afterKey))) { // No
paging if (!isset($result["link"]) || !$result["link"]) break; // PArse the
link and extract next key for paging URL list($path, $qs) = explode("?",
$result["link"], 2); parse_str($qs, $uri); $afterKey = $uri['afterKey']; }
$this->sports->listSports is my function that make the call to Orchestrate
and create the Object, etc.
Cheers
Nicolas
On Wed, Mar 4, 2015 at 8:08 AM, jamesmstone notifications@github.com
wrote:
@SocalNick https://github.com/SocalNick Sorry for hassling you with a
question about this - but i cant seem to figure this out. How do you use
getNext() to actually load the next pages body of data? Rather then just
give the API's Endpoint for the next page of data.Below is my attempt at it ( hopefully that explains what I mean better) -
I think I should instead be changing what $evFetchOp->getEndpoint()
returns. But I'm really not sure.Thanks
$results = []; $i = 0; do { if ($i == 0) { //first run $evFetchOp = new EventListOperation("users", $this->userID, "timeline", 100, $this->startTime, null, $this->endTime); } else { //other runs $evFetchOp = $evObject->getNext(); // i think i should instead be changing what $evFetchOp->getEndpoint() returns. } $evObject = $this->client->execute($evFetchOp); array_merge($results, $evObject->getValue()["results"]); $i++; } while ($evObject->getNext()); return $results;
—
Reply to this email directly or view it on GitHub
#11 (comment)
.
Nicolas Menciere
Founder and CTO
Sport Archive Inc.
@sportarc Thanks, that perfectly answered my question
I noticed this while working on recent release. Having getNextEventListObject method would be nice. I welcome the PR!