<?php
-
+/**
+ * @file include/salmon.php
+ */
use Friendica\Network\Probe;
+use Friendica\Util\Xml;
require_once 'include/crypto.php';
-function get_salmon_key($uri, $keyhash) {
+function get_salmon_key($uri, $keyhash)
+{
$ret = array();
logger('Fetching salmon key for '.$uri);
logger('Key located: ' . print_r($ret, true));
if (count($ret) == 1) {
-
// We only found one one key so we don't care if the hash matches.
// If it's the wrong key we'll find out soon enough because
// message verification will fail. This also covers some older
-function slapper($owner, $url, $slap) {
-
+function slapper($owner, $url, $slap)
+{
// does contact have a salmon endpoint?
if (! strlen($url)) {
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
- $salmon = xml::from_array($xmldata, $xml, false, $namespaces);
+ $salmon = Xml::from_array($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
// check for success, e.g. 2xx
if ($return_code > 299) {
-
logger('GNU Social salmon failed. Falling back to compliant mode');
// Now try the compliant mode that normally isn't used for GNU Social
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
- $salmon = xml::from_array($xmldata, $xml, false, $namespaces);
+ $salmon = Xml::from_array($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
- $salmon = xml::from_array($xmldata, $xml, false, $namespaces);
+ $salmon = Xml::from_array($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
}
logger('slapper for '.$url.' returned ' . $return_code);
+
if (! $return_code) {
- return(-1);
+ return -1;
}
+
if (($return_code == 503) && (stristr($a->get_curl_headers(), 'retry-after'))) {
- return(-1);
+ return -1;
}
+
return ((($return_code >= 200) && ($return_code < 300)) ? 0 : 1);
}