-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstagram.php
More file actions
54 lines (41 loc) · 1.35 KB
/
Copy pathinstagram.php
File metadata and controls
54 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
class Instagram {
public $url;
public $urls = array();
public function __construct($anchor) {
$this->url = 'https://instagram.com/p/'.$anchor;
$this->fetchUrls();
}
public function fetchUrls() {
$html = file_get_contents($this->url) or die();
if ($html === false) die();
$doc = new DOMDocument();
$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('meta');
$tagx = array();
$i = 0;
foreach ($tags as $tag) {
foreach ($tag->attributes as $attr) {
$i++;
$image_condition = strcmp(strtolower($attr->value), "og:image");
//$video_condition = strcmp(strtolower($attr->value), "og:video");
$video_condition = strcmp(strtolower($attr->value), "og:video:secure_url");
if ($image_condition === 0) {
array_push($tagx, $tag);
continue;
}
if ($video_condition === 0) {
array_push($tagx, $tag);
break;
}
}
}
foreach ($tagx as $tag) {
foreach ($tag->attributes as $attr) {
if (strlen($attr->value) > 50)
array_push($this->urls, $attr->value);
}
}
}
}
?>