@@ -112,6 +112,8 @@ public function login($username, $password) {
112
112
113
113
$ this ->cache = new SnapchatCache ();
114
114
$ this ->cache ->set ('updates ' , $ result );
115
+
116
+ return $ result ;
115
117
}
116
118
else {
117
119
return FALSE ;
@@ -367,33 +369,36 @@ function getFriendStories($force = FALSE) {
367
369
* An array of user objects or FALSE on failure.
368
370
*/
369
371
public function findFriends ($ numbers , $ country = 'US ' ) {
370
- $ numbers = array_flip ($ numbers );
372
+ $ batches = array_chunk ( array_flip ($ numbers), 30 , TRUE );
371
373
372
374
// Make sure we're logged in and have a valid access token.
373
375
if (!$ this ->auth_token || !$ this ->username ) {
374
376
return FALSE ;
375
377
}
376
378
377
- $ timestamp = parent ::timestamp ();
378
- $ result = parent ::post (
379
- '/find_friends ' ,
380
- array (
381
- 'countryCode ' => $ country ,
382
- 'numbers ' => json_encode ($ numbers ),
383
- 'timestamp ' => $ timestamp ,
384
- 'username ' => $ this ->username ,
385
- ),
386
- array (
387
- $ this ->auth_token ,
388
- $ timestamp ,
389
- )
390
- );
379
+ $ results = array ();
380
+ foreach ($ batches as $ batch ) {
381
+ $ timestamp = parent ::timestamp ();
382
+ $ result = parent ::post (
383
+ '/find_friends ' ,
384
+ array (
385
+ 'countryCode ' => $ country ,
386
+ 'numbers ' => json_encode ($ batch ),
387
+ 'timestamp ' => $ timestamp ,
388
+ 'username ' => $ this ->username ,
389
+ ),
390
+ array (
391
+ $ this ->auth_token ,
392
+ $ timestamp ,
393
+ )
394
+ );
391
395
392
- if (isset ($ result ->results )) {
393
- return $ result ->results ;
396
+ if (isset ($ result ->results )) {
397
+ $ results = $ results + $ result ->results ;
398
+ }
394
399
}
395
400
396
- return $ result ;
401
+ return $ results ;
397
402
}
398
403
399
404
/**
0 commit comments