-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnusbot.php
101 lines (68 loc) · 2.6 KB
/
gnusbot.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* GNU Social Bot (aka. GnuSBot or GSB) is a bot to publish rss/feeds to GNUSocial
*
* @Autor: @tuxxus
* @Url: http://www.tuxxus.com
* @Version: 0.0.1
*
**/
require_once("inc/gnusbot-config.inc.php");
require_once("inc/load-libs.inc.php");
$simple_feed = new SimplePie();
foreach ($gnusbot_feeds as $a_feed => $feed){
$simple_feed->set_feed_url($feed["url"]);
// Disable Cache
$simple_feed->enable_cache(false);
// Run SimplePie.
$simple_feed->init();
// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$simple_feed->handle_content_type();
echo $simple_feed->get_title()."<br />";
echo $simple_feed->get_permalink()."<br />";
echo "<hr />";
// echo $simple_feed->get_description()."<hr />";
foreach ($simple_feed->get_items(0, GSB_MAX_PUBLISH) as $item){
// init the gnusbot class
$gnusbot = new gnusbot(Array(
'timestamp' => $item->get_date('YmdHis'),
'feedname' => $simple_feed->get_permalink(),
'path_control_files' => GSB_PATH_CONTROL_FILES
));
// check if the item/post needs to be published (wasn't published earlier)
if (TRUE == $gnusbot->need_to_publish()){
// define status
$status = $item->get_title();
$status .= " ";
$status .= $item->get_permalink();
$status .= " ";
$status .= $feed["ref"];
// for each account to publish, do the job
foreach ($gnusbot_api as $account){
echo $status;
$publish_result = $gnusbot->publish(Array(
"status" => $status,
"username" => $account['username'],
"password" => $account['password'],
"api_uri" => $account['api_uri']
));
$ret = $gnusbot->log_publish();
if (FALSE != $ret && FALSE != $publish_result){
echo " - PUBLISHED<br />\r\n";
}else{
echo " - ERROR<br />\r\n";
}
}
}else{
// DO NOTHIN'
}
/* echo $item->get_title()."<br />";
echo $item->get_permalink()."<br />";
echo $item->get_description()."<br />";
echo $item->get_date('Y-m-d H:i:s')."<br />";
echo "<hr />";
*/
}
}
echo ">JOB DONE!";
?>