· 6 years ago · Aug 29, 2019, 09:02 AM
1<?php
2Class Minibots
3{
4 private $file_size = 0;
5 private $max_file_size = 5000;
6 private $file_downloaded = "";
7 // private $notifyNmaOpened = false;
8 public $use_file_get_contents = "no" ; // [ yes | no | https ]
9 // yes = aways, no = always cURL, https = only for https calls
10
11 public function __construct () {
12
13 }
14
15 /*
16 get the IP address of the connected user
17 */
18 public function getIP() {
19 $ip="";
20 if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
21 else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
22 else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
23 else $ip = "";
24 return $ip;
25 }
26
27
28
29 /*
30 add days to a date
31 */
32 public function dayadd($days,$date=null , $format="d/m/Y"){
33 return date($format,strtotime($days." days",strtotime( $date ? $date : date($format) )));
34 }
35
36
37
38
39 /*
40 this function return the html attribute of a given tag
41 (use for scraping data)
42 */
43 public function attr($s,$attrname) {
44 preg_match_all('#\s*('.$attrname.')\s*=\s*["]([^"]*)["]\s*#i', $s, $x);
45 if (count($x)>=3 && isset($x[2][0])) return isset($x[2][0]) ? $x[2][0] : "";
46 preg_match_all('#\s*('.$attrname.')\s*=\s*[\']([^\']*)[\']\s*#i', $s, $x);
47 if (count($x)>=3 && isset($x[2][0])) return isset($x[2][0]) ? $x[2][0] : "";
48 return "";
49 }
50
51
52
53 /*
54 return the array of matches when searching for a
55 tag serie while scraping html
56 $return can be "ALL" | "INNER" | "OUTER"
57 */
58 public function getTags($tagname,$text,$return="ALL") {
59 $tagname = strtolower($tagname);
60 if($tagname=="img" || $tagname=="br" || $tagname=="input") {
61 // autoclose
62 preg_match_all('#<'.$tagname.'[^>]*?>#Uis', $text, $s);
63 } else {
64 preg_match_all('#<'.$tagname.'[^>]*?>(.*)</'.$tagname.'>#Uis', $text, $s);
65 }
66 if($return=="ALL") return $s;
67 if($return=="INNER") return $s[1];
68 if($return=="OUTER") return $s[0];
69 return $s;
70 }
71
72
73
74
75 /*
76 this function makes a relative url an absolute merging
77 properly the url and the link
78 */
79 public function makeabsolute($url,$link) {
80 $p = parse_url($url);
81 if (strpos( $link,"http://")===0 ) return trim($link);
82 if (strpos( $link,"https://")===0 ) return trim($link);
83 if($p['scheme']."://".$p['host']==$url && $link[0]!="/" && $link!=$url) return trim($p['scheme']."://".$p['host']."/".$link);
84 if (strpos( $link, "/")===0) return trim($p['scheme']."://".$p['host'].$link);
85 return trim(str_replace(substr(strrchr($url, "/"), 1),"",$url).$link);
86 }
87
88
89
90 /*
91 Retrieves a page with some parameters in POST.
92 The parameters should be passed like this:
93 $vars = array("name"=>value, "name2"=>value2);
94 */
95 public function getPagePost($url,$vars) {
96 if (!function_exists("curl_init")) die("getPagePost needs CURL module, please install CURL on your php.");
97 $s = "";
98 foreach($vars as $k=>$v) $s.= ($s?"&":"") . $k."=".rawurlencode($v);
99
100 $curl = curl_init();
101 curl_setopt($curl, CURLOPT_URL, $url);
102 curl_setopt($curl, CURLOPT_POST, 1);
103 curl_setopt($curl, CURLOPT_POSTFIELDS, $s);
104 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
105 $curl_results = curl_exec ($curl);
106 curl_close ($curl);
107 return $curl_results;
108 }
109
110
111
112 public function getRandomUserAgent()
113 {
114 $userAgents=array(
115 "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6",
116 "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)",
117 "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
118 "Opera/9.20 (Windows NT 6.0; U; en)",
119 "Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8",
120 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.50",
121 "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1) Opera 7.02 [en]",
122 "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; fr; rv:1.7) Gecko/20040624 Firefox/0.9",
123 "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/48 (like Gecko) Safari/48"
124 );
125 $random = rand(0,count($userAgents)-1);
126
127 return $userAgents[$random];
128 }
129
130
131 /*
132 this method gets a page, use this to build your crawler, it calls curl.
133 on some servers file_get_contents works better, so it uses
134 the parameter "use_file_get_contents" to switch from curl to file_get_contents
135 doesn't handle POST data.
136 */
137 public function getPage($url, $max_file_size=0) {
138
139 if (!function_exists("curl_init")) die("getPage needs CURL module, please install CURL on your php.");
140 $ch = curl_init();
141
142 $https = preg_match("/^https/i",$url);
143 //echo $url;
144 if($this->use_file_get_contents=="yes") return file_get_contents($url);
145
146 if($https && $this->use_file_get_contents=="https") {
147 return file_get_contents($url);
148 }
149
150 // // Activation de l'utilisation d'un serveur proxy
151 // curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
152 // curl_setopt($ch, CURLOPT_PROXY, '176.31.69.180 :8080');
153 // // curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_ident);
154
155
156 curl_setopt($ch, CURLOPT_URL, $url);
157 curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
158 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects (abilitato per wikipedia)
159 if($https) {
160 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
161 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
162 //curl_setopt($ch, CURLOPT_CERTINFO, true);
163 //curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
164 }
165 curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate,sdch');
166 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
167 //curl_setopt($ch, CURLOPT_PORT, 80); //Set the port number
168 curl_setopt($ch, CURLOPT_TIMEOUT, 15); // times out after 15s
169 curl_setopt($ch, CURLOPT_USERAGENT, $this->getRandomUserAgent()); // Webbot name
170 curl_setopt($ch,CURLOPT_HTTPHEADER,array('Accept-Language: en-US;q=0.6,en;q=0.4'));
171 if($max_file_size>0) {
172 // if you want to reduce download size, set the byte size limit
173 $this->max_file_size = $max_file_size;
174 curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'on_curl_header'));
175 curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($this, 'on_curl_write'));
176 }
177 $web_page = curl_exec($ch);
178 if(strlen($web_page) <= 1 && $max_file_size>0) {
179 $web_page = $this->file_downloaded;
180 }
181 if(curl_error($ch))
182 return curl_error($ch);
183
184 return $web_page;
185 }
186
187
188
189
190 /*
191 this method returns all the links inside a given url
192 skip bad urls (javascript, mailto...), make all urls absolute
193 flags to skip some links to particular extensions (pdf,zip,jpg...)
194 and to follow external urls.
195 */
196 public function findLinks($url, $web_page, $FOLLOW_EXTERNAL=false, $SKIP_EXTENSIONS="") {
197 $stop_host = "";
198 $exts = array();
199 if($FOLLOW_EXTERNAL==false) {
200 $temp = parse_url($url);
201 if(!$temp['host']) {
202 die("Can't determine host, plaese check starting url: ".$url);
203 } else {
204 $stop_host = $temp['host'];
205 }
206 }
207 if($SKIP_EXTENSIONS){
208 $exts = explode(",",$SKIP_EXTENSIONS);
209 if(empty($exts)) $SKIP_EXTENSION="";
210 }
211
212 //search links
213 preg_match_all('#<a([^>]*)?>(.*)</a>#Uis', $web_page, $a_array);
214 $outAr = array();
215 if(isset($a_array[1])) {
216 foreach($a_array[1] as $link) {
217 $href = $this->attr($link,"href");
218 if($href!=""
219 && !preg_match("/^javascript:/",$href)
220 && !preg_match("/^#/",$href)
221 && !preg_match("/^mailto:/",$href)
222 ) {
223 $temp = $this->makeabsolute($url,str_replace(" ","%20",$href));
224 if($FOLLOW_EXTERNAL==false && $stop_host) {
225 $temp2 = parse_url($temp);
226 if($temp2['host']!=$stop_host) $temp="";
227 }
228 if($SKIP_EXTENSIONS){
229 foreach($exts as $e){
230 if(preg_match("/(\.".$e.")$/",$temp)) { $temp=""; break;}
231 }
232 }
233 if($temp) $outAr[] = $temp;
234 }
235 }
236 }
237 return array_unique($outAr);
238 }
239
240
241
242
243 /*
244 this method returns all the emails contained
245 in the page.
246 */
247 public function findEmails($page) {
248 preg_match_all(
249 '/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}\b/i',
250 $page,
251 $matches
252 );
253 $outAr = array();
254 foreach(array_unique($matches[0]) as $email) {
255 //echo "<code>".$email."</code><br/>";
256 $outAr[] = $email;
257 }
258 return $outAr;
259 }
260
261
262
263
264 /*
265 remove all html and tags from a url and get only the text
266 TO DO: could be improved to use only useful tags (headings and paragraphs)
267 */
268 public function justText($text) {
269 $text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $text);
270 $text = preg_replace("/[\n\r\t]/"," ",strip_tags($text));
271 $text = preg_replace("/( +)/"," ",strip_tags($text));
272 return $text;
273 }
274
275
276 /*
277 private function to handle file size check and prevent downloading too much
278 */
279 private function on_curl_header($ch, $header) {
280 $trimmed = rtrim($header);
281 if (preg_match('/^Content-Length: (\d+)$/i', $trimmed, $matches)) {
282 $file_size = (float)$matches[1];
283 if ($file_size > $this->max_file_size) {
284 // stop if bigger
285 return -1;
286 }
287 }
288 return strlen($header);
289 }
290
291
292
293
294 /*
295 like the previous one, private function to handle file size check and prevent downloading too much
296 */
297 private function on_curl_write($ch, $data) {
298 $bytes = strlen($data);
299 $this->file_size += $bytes;
300 $this->file_downloaded .= $data;
301 if ($this->file_size > $this->max_file_size) {
302 // stop if bigger
303 return -1;
304 }
305 return $bytes;
306 }
307
308
309
310
311 /*
312 private function to get remote file size
313 TO DO: Does it work with https?
314 */
315 private function getRemoteFileSize($url) {
316 if (substr($url,0,4)=='http') {
317 $x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
318 if ( strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0 ) { $x = $x['content-length'][1]; }
319 else { $x = $x['content-length']; }
320 }
321 else { $x = @filesize($url); }
322 return $x;
323 }
324
325
326
327
328 /*
329 private function to get the http response code for a url
330 TO DO: Does it work with https?
331 */
332 private function getHttpResponseCode($url) {
333 if (!function_exists("curl_init")) die("getHttpResponseCode needs CURL module, please install CURL on your php.");
334 // 404 not found, 403 forbidden...
335 $ch = @curl_init($url);
336 @curl_setopt($ch, CURLOPT_HEADER, TRUE);
337 @curl_setopt($ch, CURLOPT_NOBODY, TRUE);
338 @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
339 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
340 $status = array();
341 preg_match('/HTTP\/.* ([0-9]+) .*/', @curl_exec($ch) , $status);
342 return isset($status[1]) ? $status[1] : null;
343 }
344
345
346
347
348 /*
349 Copy a remote url to your local server
350 */
351 public function copyFile($url,$filename){
352 // copy remote file to server
353 $file = fopen ($url, "rb");
354 if (!$file) return false; else {
355 $fc = fopen($filename, "wb");
356 while (!feof ($file)) {
357 $line = fread ($file, 1028);
358 fwrite($fc,$line);
359 }
360 fclose($fc);
361 return true;
362 }
363 }
364
365
366
367
368 /*
369 Google spell suggest.
370 Usage example:
371 $obj = New Minibots();
372 $word = $obj->doSpelling("wikipezia");
373 --> wikipedia
374 */
375 public function doSpelling($q) {
376 // grab google page with search
377 $web_page = file_get_contents( "https://www.google.it/search?q=" . urlencode($q) );
378 //echo $web_page;
379 //die;
380
381 // put anchors tag in an array
382 preg_match_all('#<a([^>]*)?>(.*)</a>#Us', $web_page, $a_array);
383 for($j=0;$j<count($a_array[0]);$j++) {
384 // find link with spell suggestion and return it
385 if(stristr($a_array[0][$j],"spell=1&")) return strip_tags($a_array[0][$j]);
386 //if(stristr($a_array[0][$j],"class=\"spell\"")) return strip_tags($a_array[0][$j]);
387 }
388 return $q; //if no results returns the q value
389 }
390
391
392
393
394 /*
395 Make a tiny url with tinyurl.com free service.
396 Usage example:
397 $obj = New Minibots();
398 $short_url = $obj->doShortURL("http://www.this.is.a.long.url/words-words-words");
399 --> http://tinyurl.com/aiIAa (fake values)
400 */
401 public function doShortURL($longUrl) {
402 $short_url= file_get_contents('http://tinyurl.com/api-create.php?url=' . $longUrl);
403 return $short_url;
404 }
405
406
407
408
409 /*
410 Convert back from a tiny url to a long url, work also with urls of other services
411 like goo.gl, bit.ly and others. This method works to handle all redirects, not only
412 the ones from shorten url services.
413 Usage example:
414 $obj = New Minibots();
415 $long_url = $obj->doShortURLDecode("http://tinyurl.com/aiIAa");
416 --> http://www.this.is.a.long.url/words-words-words (fake values)
417 */
418 public function doShortURLDecode($url) {
419 if (!function_exists("curl_init")) die("doShortURLDecode needs CURL module, please install CURL on your php.");
420 $ch = @curl_init($url);
421 @curl_setopt($ch, CURLOPT_HEADER, TRUE);
422 @curl_setopt($ch, CURLOPT_NOBODY, TRUE);
423 @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
424 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
425 $out = @curl_exec($ch);
426 preg_match('/Location: (.*)\n/i', $out, $a);
427 if (!isset($a[1])) return $url;
428 return trim($a[1]);
429 }
430
431 /*
432 Check if an mp3 URL is an mp3.
433 Usage example:
434 $obj = New Minibots();
435 $check = $obj->checkMp3("http://www.artintent.it/Kalimba.mp3");
436 --> true
437 */
438 public function checkMp3($url) {
439 if (!function_exists("curl_init")) die("checkMp3 needs CURL module, please install CURL on your php.");
440 $a = parse_url($url);
441 if(checkdnsrr(str_replace("www.","",$a['host']),"A") || checkdnsrr(str_replace("www.","",$a['host']))) {
442 $ch = @curl_init();
443 @curl_setopt($ch, CURLOPT_URL, $url);
444 @curl_setopt($ch, CURLOPT_HEADER, 1);
445 @curl_setopt($ch, CURLOPT_NOBODY, 1);
446 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
447 @curl_setopt($ch, CURLOPT_TIMEOUT, 15);
448 $results = explode("\n", trim(curl_exec($ch)));
449 $mime = "";
450 foreach($results as $line) {
451 if (strtok($line, ':') == 'Content-Type') {
452 $parts = explode(":", $line);
453 $mime = trim($parts[1]);
454 }
455 }
456 return $mime=="audio/mpeg";
457 } else {
458 return false;
459 }
460 }
461
462
463
464
465 /*
466 Check if a URL exists, like file_exists, but for remote urls.
467 Usage example:
468 $obj = new Minibots();
469 $check = $obj->url_exists("http://en.wikipedia.org/wiki/Barack_Obama");
470 --> true
471 */
472 public function url_exists($url) {
473 return ($this->getHttpResponseCode($url) == 200);
474 }
475
476
477
478
479
480
481 /*
482 Function to search for images with a key or a phrase
483 scraping contents from www.picsearch.com
484 $pics = $mb->getImage("apple fruit");
485 echo "<img src=\"".$pics[rand(0,count($pics)-1)]."\"/>";
486 */
487 public function getImage($key) {
488 //
489 // scraping content from picsearch
490 $temp = file_get_contents("http://www.picsearch.com/index.cgi?q=".urlencode($key));
491 preg_match_all("/<img class=\"thumbnail\" src=\"([^\"]*)\"/",$temp,$ar);
492 if(is_array($ar[1])) return $ar[1];
493 return false;
494 }
495 /*
496 use the previous functions results to get a bigger picture
497 of the result.
498 */
499 public function getImageBig($pic) {
500 // this service doesn't work always since 04/01/2019
501 $ar = preg_split("/[\?\&]/",str_replace("&","&",$pic));
502
503 if(isset($ar[1])) {
504 //echo "http://www.picsearch.com/imageDetail.cgi?id=".$ar[1]."&start=1&q=";
505 $temp = file_get_contents("http://www.picsearch.com/imageDetail.cgi?id=".$ar[1]."&start=1&q=");
506 preg_match_all("/<a( rel=\"nofollow\")? href=\"([^\"]*)\">Full-size image<\/a>/i",$temp,$ar);
507 if(isset($ar[2][0])) {
508 return $ar[2][0];
509 }
510 }
511 return "";
512 }
513
514
515
516
517
518 /*
519 send a ping to pingomatic services to help bloggers
520 to index their posts in search engines;
521 TO DO: not tested from a long time.
522 */
523 public function pingomatic($title,$url,$feed="") {
524 $curl = curl_init();
525 curl_setopt($curl, CURLOPT_URL, "http://pingomatic.com/ping/?title=".urlencode($title)."&blogurl=".urlencode($url)."&rssurl=".urlencode($feed)."&chk_weblogscom=on&chk_blogs=on&chk_feedburner=on&chk_newsgator=on&chk_myyahoo=on&chk_pubsubcom=on&chk_blogdigger=on&chk_weblogalot=on&chk_newsisfree=on&chk_topicexchange=on&chk_google=on&chk_tailrank=on&chk_skygrid=on&chk_collecta=on&chk_superfeedr=on");
526 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
527 curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"); // Webbot name
528 $curl_results = curl_exec ($curl);
529 curl_close ($curl);
530 //echo $curl_results;
531 return preg_match("/(Pinging complete!)/",$curl_results);
532 }
533
534
535
536
537 /*
538 get instagram follower for a specified user
539 */
540 function getInstagramFollowers($nick) {
541 $p = file_get_contents("https://www.instagram.com/".$nick);
542 preg_match("/window\._sharedData ?= (.*)<\/script>/Uis",$p,$a);
543 $c = trim(preg_replace("/;$/","",trim($a[1])));
544 $c = trim(preg_replace("/\n/","",trim($c)));
545 $b = json_decode($c);
546 if(isset($b->entry_data->ProfilePage[0]->graphql->user->edge_followed_by->count)) return
547 $b->entry_data->ProfilePage[0]->graphql->user->edge_followed_by->count;
548 return 0;
549 }
550
551
552
553 /*
554 get all the info for a specific Instagram picture
555 */
556 public function getInstagramPic($url) {
557 $code = explode("/",preg_replace("#/$#","",$url));
558 $p = $this->getPage("https://www.instagram.com/p/".$code[count($code)-1]."/?__a=1");
559 $o = json_decode($p);
560 $thumb = str_replace("/s640x640/","/s150x150/",$o->graphql->shortcode_media->display_url); // not working
561 $low = str_replace("/s640x640/","/s320x320/",$o->graphql->shortcode_media->display_url); // not working
562 $out = array(
563 "low_resolution"=>$low,
564 "thumbnail"=>$thumb,
565 "full"=>$o->graphql->shortcode_media->display_url,
566 "standard"=>$o->graphql->shortcode_media->display_url,
567 "date"=>date("Y-m-d H:i:s", $o->graphql->shortcode_media->taken_at_timestamp),
568 "caption"=> $o->graphql->shortcode_media->edge_media_to_caption->edges[0]->node->text,
569 "likes"=>$o->graphql->shortcode_media->edge_media_preview_like,
570 "comments"=> $o->graphql->shortcode_media->edge_media_to_comment,
571 "owner"=>$o->graphql->shortcode_media->owner,
572 "is_video"=>$o->graphql->shortcode_media->is_video
573 );
574 return $out;
575 }
576
577
578
579
580 /*
581 get last Instagram pics and user data from instagram
582 without the official api
583 */
584 public function getInstagramPics($user) {
585 if(filter_var($user, FILTER_VALIDATE_URL))
586 $p = $user;
587 else
588 $p = "https://www.instagram.com/".$user."/";
589
590 $p = $this->getPage($p);
591 // get a big json data
592 preg_match("/window\._sharedData ?= (.*)<\/script>/Uis",$p,$a);
593 $c = trim(preg_replace("/;$/","",trim($a[1])));
594 $c = trim(preg_replace("/\n/","",trim($c)));
595 $b = json_decode($c);
596
597 if(isset($b->entry_data->ProfilePage[0]->graphql->user) && isset(
598 $b->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges
599 )) {
600 $a = array();
601 if(isset($b->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges)) {
602 foreach($b->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges as $pic) {
603
604
605 $a[] = array(
606 "link"=>"https://www.instagram.com/p/".$pic->node->shortcode."/",
607 "code"=>$pic->node->shortcode,
608 "likes"=>isset($pic->node->edge_liked_by->count) ? $pic->node->edge_liked_by->count : 0,
609 "preview"=>isset($pic->node->edge_media_preview_like->count) ? $pic->node->edge_media_preview_like->count : 0,
610 "comments"=>isset($pic->node->edge_media_to_comment->count) ? $pic->node->edge_media_to_comment->count : 0,
611 "created"=>date("Y-m-d H:i:s",$pic->node->taken_at_timestamp),
612 "text"=>isset($pic->node->edge_media_to_caption->edges[0]->node->text) ? $pic->node->edge_media_to_caption->edges[0]->node->text : "",
613 "low_resolution"=>$pic->node->thumbnail_src,
614 "standard_resolution"=>$pic->node->thumbnail_src,
615 "full_resolution"=>$pic->node->display_url,
616 "thumbnail"=>$pic->node->thumbnail_src,
617 "width"=>$pic->node->dimensions->width,
618 "height"=>$pic->node->dimensions->height,
619 );
620 }
621 } else {
622 $a="private user";
623 }
624
625 $q=0;
626
627
628
629
630 if(isset($b->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->count)) $q=$b->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->count;
631
632 //$b->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media = null;
633 return array(
634 "user"=>$b->entry_data->ProfilePage[0]->graphql->user,
635 "pics"=>$a,
636 "totalcount"=>$q
637 );
638 }
639 return false;
640 }
641
642
643
644
645
646
647
648
649
650
651}
652
653
654
655 $mb = new Minibots();
656 var_dump($mb->getInstagramPics("xsqueezie"));
657 echo "<hr>";
658 echo htmlspecialchars($mb->getPage("https://www.instagram.com/xsqueezie"));
659?>