Ejemplo n.º 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-php/src/IndieWeb/MentionClient.php';
     // Proxy connection string provided
     $proxystring = false;
     if (!empty(\Idno\Core\site()->config()->proxy_string)) {
         $proxystring = \Idno\Core\site()->config()->proxy_string;
     }
     $client = new \IndieWeb\MentionClient($pageURL, $text, $proxystring);
     return $client->sendSupportedMentions();
 }
Ejemplo n.º 2
0
 public function discover_endpoint(Request $request, Response $response)
 {
     if (!$this->_is_logged_in($request, $response)) {
         return $response;
     }
     $targetURL = $request->get('target');
     if (!Telegraph\Webmention::isProbablySupported($targetURL)) {
         $status = 'none';
         $cached = -1;
     } else {
         // Cache the discovered result
         $cacheKey = 'telegraph:discover_endpoint:' . $targetURL;
         if ($request->get('ignore_cache') == 'true' || !($status = redis()->get($cacheKey))) {
             $client = new IndieWeb\MentionClient();
             $endpoint = $client->discoverWebmentionEndpoint($targetURL);
             if ($endpoint) {
                 $status = 'webmention';
             } else {
                 $endpoint = $client->discoverPingbackEndpoint($targetURL);
                 if ($endpoint) {
                     $status = 'pingback';
                 } else {
                     $status = 'none';
                 }
             }
             $cached = false;
             redis()->setex($cacheKey, 600, $status);
         } else {
             $cached = true;
         }
     }
     $response->headers->set('Content-Type', 'application/json');
     $response->setContent(json_encode(['status' => $status, 'cached' => $cached]));
     return $response;
 }
Ejemplo n.º 3
0
<?php

// Note: if installing with composer you should require 'vendor/autoload.php' instead
include 'src/IndieWeb/MentionClient.php';
$url = 'https://github.com/aaronpk/mention-client';
$client = new IndieWeb\MentionClient($url);
$client->debug = true;
$sent = $client->sendSupportedMentions();
echo "Sent {$sent} mentions\n";
Ejemplo n.º 4
0
<?php

// Note: if installing with composer you should require 'vendor/autoload.php' instead
include 'src/IndieWeb/MentionClient.php';
$url = 'https://github.com/aaronpk/mention-client';
$client = new IndieWeb\MentionClient();
$client->enableDebug();
$sent = $client->sendMentions($url);
echo "Sent {$sent} mentions\n";