예제 #1
0
 /**
  * Pings mentions from a given page to any linked pages
  * @param $pageURL Page URL
  * @param string $text The text to mine for links
  * @return int The number of pings that were sent out
  */
 static function pingMentions($pageURL, $text)
 {
     // Load webmention-client
     require_once \Idno\Core\site()->config()->path . '/external/mention-client/mention-client.php';
     $client = new \MentionClient($pageURL, $text);
     return $client->sendSupportedMentions();
 }
예제 #2
0
 /**
  * send notification
  */
 public function execute()
 {
     // normal google hub
     \PubSubHubbub::push("http://pubsubhubbub.appspot.com/", "hub.mode=publish&hub.url=" . urlencode("http://api." . \sfConfig::get("app_settings_host") . "/feeds/global"));
     \PubSubHubbub::push("http://pubsubhubbub.superfeedr.com/", "hub.mode=publish&hub.url=" . urlencode("http://api." . \sfConfig::get("app_settings_host") . "/feeds/global"));
     // @todo googles Social Data Hub
     // \PubSubHubbub::push("http://pshbsubber.appspot.com/sub/spreadly", "", array("X-Hub-Signature" => "sha1=secret_checksum"));
     $dm = \MongoManager::getDM();
     $ya = $dm->getRepository("Documents\\YiidActivity")->find(new \MongoId($this->getYiidActivityId()));
     if (!$ya) {
         return false;
     }
     // send webmentions or pingbacks
     $mc = new \MentionClient(\sfConfig::get('app_settings_my_url') . "/share/" . $ya->getId());
     $mc->sendSupportedMentions($ya->getUrl());
     $dp = $ya->getDomainProfile();
     if (!$dp) {
         return false;
     }
     $ds = $dp->getDomainSubscriptions();
     if (!$ds) {
         return false;
     }
     foreach ($ds as $s) {
         $info = \PubSubHubbub::push($s->getCallback(), $this->toJson($ya), array("Content-Type: application/json"));
         // all good -- anything in the 200 range
         if (substr($info['http_code'], 0, 1) == "2") {
             $this->finished();
         } elseif ($info['http_code'] == 408) {
             $this->reschedule(array("code" => 408, "message" => "Server Timeout"));
         } else {
             $this->failed(array("code" => $info['http_code'], "message" => "PuSH failed"));
         }
     }
 }
예제 #3
0
 public static function enableDebug($enabled)
 {
     self::$_debugStatic = $enabled;
 }
예제 #4
0
파일: example.php 프로젝트: phpsource/idno
<?php

include 'mention-client.php';
$url = 'https://github.com/aaronpk/mention-client';
$client = new MentionClient($url);
$client->debug = true;
$sent = $client->sendSupportedMentions();
echo "Sent {$sent} mentions\n";