-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
|
||
|
||
|
||
$_SERVER['HTTP_HOST'] = 'v1.chregu.tv'; | ||
|
||
|
||
define("R2T_PROJECT_DIR",dirname(__FILE__)); | ||
ini_set("include_path",R2T_PROJECT_DIR."/inc/:/var/www/zf-trunk/:".ini_get("include_path")); | ||
|
||
|
||
|
||
require_once( "Zend/Feed/Pubsubhubbub/Storage/Filesystem.php"); | ||
|
||
$storage = new Zend_Feed_Pubsubhubbub_Storage_Filesystem; | ||
$storage->setDirectory(R2T_PROJECT_DIR."/tmp"); | ||
|
||
require_once( "Zend/Feed/Pubsubhubbub/Subscriber/Callback.php"); | ||
|
||
$callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback; | ||
$callback->setStorage($storage); | ||
|
||
$token = substr($_SERVER['PATH_INFO'],1); | ||
|
||
|
||
$callback->setSubscriptionKey($token); | ||
|
||
$callback->handle(); | ||
|
||
if ($callback->hasFeedUpdate() || isset($_GET['doit']) ) { | ||
$data = $callback->getFeedUpdate(); | ||
|
||
$key = md5($data); | ||
file_put_contents(R2T_PROJECT_DIR . '/tmp/updates/' . $key, $data); | ||
$command = "/usr/bin/php /home/chregu/rss2twi.php/rss2twitter.php"; | ||
$pcommand = $command . ' > /dev/null &'; | ||
pclose(popen($pcommand, 'r')); | ||
/* $this->_helper->getHelper('Spawn') | ||
->setScriptPath(APPLICATION_ROOT . '/scripts/zfrun.php'); | ||
$this->_helper->spawn( | ||
array('--key'=>$key), 'process', 'callback' | ||
);*/ | ||
} | ||
|
||
$callback->sendResponse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
$_SERVER['HTTP_HOST'] = 'v1.chregu.tv'; | ||
|
||
|
||
define("R2T_PROJECT_DIR",dirname(__FILE__)); | ||
ini_set("include_path",R2T_PROJECT_DIR."/inc/:/var/www/zf-trunk/:".ini_get("include_path")); | ||
|
||
require_once 'Zend/Feed/Reader.php'; | ||
|
||
|
||
//$topic = 'http://chregu.tv/blog/atom.xml'; | ||
$topic = 'http://www.planet-php.net/atom/'; | ||
$feed = Zend_Feed_Reader::import($topic); | ||
|
||
$feedTopicUri = $feed->getFeedLink(); | ||
|
||
/** | ||
* The feed may advertise one or more Hub Endpoints we can use. | ||
* We may subscribe to the Topic using one or more of the Hub | ||
* Endpoints advertised (good idea in case a Hub goes down). | ||
*/ | ||
$feedHubs = $feed->getHubs(); | ||
|
||
/** | ||
* Carry out subscription operation... | ||
*/ | ||
|
||
require_once( "Zend/Feed/Pubsubhubbub/Storage/Filesystem.php"); | ||
$storage = new Zend_Feed_Pubsubhubbub_Storage_Filesystem; | ||
$storage->setDirectory(R2T_PROJECT_DIR."/tmp"); | ||
$options = array( | ||
'topicUrl' => $feedTopicUri, | ||
'hubUrls' => $feedHubs, | ||
'storage' => $storage, | ||
'callbackUrl' => 'http://'.$_SERVER['HTTP_HOST'].'/rss2twi/callback.php', | ||
'usePathParameter' => true, | ||
'authentications' => array( | ||
) | ||
); | ||
require_once( "Zend/Feed/Pubsubhubbub/Subscriber.php"); | ||
|
||
$subscriber = new Zend_Feed_Pubsubhubbub_Subscriber($options); | ||
$subscriber->subscribeAll(); | ||
/** | ||
* Do some checking for errors... | ||
*/ | ||
if (!$subscriber->isSuccess()) { | ||
var_dump($subscriber->getErrors()); exit; | ||
print "<br/>ERROR"; | ||
} else { | ||
|
||
error_log("SEEMS TO BE OK"); | ||
} | ||
|