uNoGS

FREEMIUM
By Admin | Updated 15 days ago | Entertainment
Popularity

9.8 / 10

Latency

933ms

Service Level

100%

Health Check

N/A

Back to All Discussions

Count and Items don't match?

Rapid account: Ma Ft
MaFt
8 years ago

Getting expiry dates for US from https://unogs-unogs-v1.p.mashape.com/api.cgi?q=get:exp:US&t=ns&st=adv and it says there are 102 in COUNT BUT the json only returns 100 in ITEMS.

UK has 70 items and correctly shows 70.

Rapid account: Annaeva 1008
annaeva1008 Commented 9 months ago

Some APIs have limitations on the number of items returned in a single request to prevent excessive data transfer. In this case, you would need to make multiple requests to retrieve all the data.
mapquest directions

Rapid account: Unogs
unogs Commented 8 years ago

MaFt you truly are a rock star!
Thanks for the great support, you are the best!

Rapid account: Ma Ft
MaFt Commented 8 years ago

And for anyone whoโ€™s curiousโ€ฆ:

$results = (object) array_merge((array) $response_1->body->ITEMS, (array) $response_2->body->ITEMS โ€ฆ)

Rapid account: Jakothan
jakothan Commented 8 years ago

Thanks for the awesome support at this site! MaFt thumbs up! unogs thanks for testing! Great! Works like a charme now! ๐Ÿ˜‰

Rapid account: Jakothan
jakothan Commented 8 years ago

should be in your inbox. ๐Ÿ˜ƒ Thank you!! ๐Ÿ˜ƒ

Rapid account: Ma Ft
MaFt Commented 8 years ago

Do you want to email me your code and I can have a look at the whole lot? Do remove your mashape key and any identifiable info etc though. mail AT maft DOT co DOT uk

Rapid account: Jakothan
jakothan Commented 8 years ago

reponse_1 and _2 starting with the correct titles as unogs wrote above. Every page has 100 titles. That seems to be correct. I'm using a string to get each title. Like this:

do { 
	foreach (datareq->body->ITEMS as ITEM) {
       ....
      }
} while (i <= $anzahl);</pre>

Rapid account: Ma Ft
MaFt Commented 8 years ago

Jakothan - difficult to say without seeing the whole code. Are you converting the json into an array for parsing? when you do an array dump for $response_1 and $response_2 are you getting page one and page 2 data being shown?

Rapid account: Jakothan
jakothan Commented 8 years ago

Hi MaFt, thanks for your inspiration. ๐Ÿ˜ƒ I have 2 requests now, every request has the correct results. But when I merge them, only the last 100 results will be shown - so as I wrote above.
Iโ€™ve merged them on this way: <pre>$results1 = (object) array_merge((array) $response_1, (array) $response_2);</pre> Have you an idea? Itโ€™s only a hobby for me, Iโ€™m not a โ€œProfessional Coderโ€ โ€ฆ ๐Ÿ˜•

Rapid account: Ma Ft
MaFt Commented 8 years ago

Create a new array.
Put each result from page 1 into an array.
Use the ITEMS divided by 100 to see how many pages you need.
Parse the next pages (if needed) and ADD those to the existing array.

THEN do you work with each item in the array.

Join in the discussion - add comment below:

Login / Signup to post new comments