forked from declanmaher/InstagramScraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
approvedImages.class.php
80 lines (63 loc) · 1.83 KB
/
approvedImages.class.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Instagram Image Approval class
* API Documentation: non
*
* @author Declan Maher
* @since 7.02.2014
* @copyright Declan Maher 2014
* @version 1.0
* @license BSD http://www.opensource.org/licenses/bsd-license.php
*/
class approvedImages {
/**
* Get approved images
*
* @return array
*/
public function get_approved_images() {
// images saved in txt file
if(is_readable('approvedImages.txt')){
$lines = file("approvedImages.txt");
return $lines;
}
else{
throw new Exception("Error: The file for saving images is not readable.");
}
}
/**
* Get approved images
*
* @param string $savedImages
*
*/
<<<<<<< HEAD
=======
>>>>>>> f1b143821875c0370200f046e2e84e7545a90e45
function insert_approved_images($savedImages) {
if(!empty($savedImages)) {
$pieces = explode(",", $savedImages);
//var_dump($pieces);
} else {
echo 'No images to save.Please go back and save Images';
}
if(is_readable('approvedImages.txt')){
if(!empty($pieces)) {
//set file name to be written to
$file ="approvedImages.txt";
// Open the file to get existing content
$fh = fopen($file, 'w') or die("can't open file");
foreach($pieces as $currentImage) {
$stringnl = $currentImage . PHP_EOL;// add new line
// Write the contents back to the file
fwrite($fh, $stringnl);
}
fclose($fh);
}
}
else{
throw new Exception("Error: The file for saving images is not readable.");
}
}
}
?>