function handle($data) { assert(is_array($data)); assert(is_string($data['salmonuri'])); assert(is_string($data['entry'])); $actor = Profile::getKV($data['actor']); Salmon::post($data['salmonuri'], $data['entry'], $actor->getUser()); // @fixme detect failure and attempt to resend return true; }
function handle($data) { assert(is_array($data)); assert(is_string($data['salmonuri'])); assert(is_string($data['entry'])); $actor = Profile::getKV($data['actor']); $target = array_key_exists('target', $data) ? Profile::getKV($data['target']) : null; Salmon::post($data['salmonuri'], $data['entry'], $actor, $target); // @fixme detect failure and attempt to resend return true; }
function handle($data) { assert(is_array($data)); assert(is_string($data['salmonuri'])); assert(is_string($data['entry'])); $actor = Profile::staticGet($data['actor']); $salmon = new Salmon(); $salmon->post($data['salmonuri'], $data['entry'], $actor); // @fixme detect failure and attempt to resend return true; }
/** * Send a Salmon notification ping immediately, and confirm that we got * an acceptable response from the remote site. * * @param mixed $entry XML string, Notice, or Activity * @param Profile $actor * @return boolean success */ public function notifyActivity($entry, Profile $actor) { if ($this->salmonuri) { return Salmon::post($this->salmonuri, $this->notifyPrepXml($entry), $actor, $this->localProfile()); } common_debug(__CLASS__ . ' error: No salmonuri for Ostatus_profile uri: ' . $this->uri); return false; }
print "\n\n"; echo "== Testing local verification ==\n\n"; $magic_env = new MagicEnvelope($envxml); $activity = new Activity($magic_env->getPayload()->documentElement); $actprofile = Profile::fromUri($activity->actor->id); $ok = $magic_env->verify($actprofile); if ($ok) { print "OK\n\n"; } else { print "FAIL\n\n"; } if (have_option('--verify')) { $url = 'http://www.madebymonsieur.com/ostatus_discovery/magic_env/validate/'; echo "== Testing remote verification ==\n\n"; print "Sending for verification to {$url} ...\n"; $client = new HTTPClient(); $response = $client->post($url, array(), array('magic_env' => $envxml)); print $response->getStatus() . "\n\n"; print $response->getBody() . "\n\n"; } if (have_option('--slap')) { $url = get_option_value('--slap'); echo "== Remote salmon slap ==\n\n"; print "Sending signed Salmon slap to {$url} ...\n"; $ok = Salmon::post($url, $entry, $profile->getUser()); if ($ok) { print "OK\n\n"; } else { print "FAIL\n\n"; } }
/** * Send a Salmon notification ping immediately, and confirm that we got * an acceptable response from the remote site. * * @param mixed $entry XML string, Notice, or Activity * @param Profile $actor * @return boolean success */ public function notifyActivity($entry, $actor) { if ($this->salmonuri) { $salmon = new Salmon(); return $salmon->post($this->salmonuri, $this->notifyPrepXml($entry), $actor); } return false; }
$envelope = $salmon->createMagicEnv($entry, $profile); echo "== Signed envelope ==\n\n"; print $envelope; print "\n\n"; echo "== Testing local verification ==\n\n"; $ok = $salmon->verifyMagicEnv($envelope); if ($ok) { print "OK\n\n"; } else { print "FAIL\n\n"; } if (have_option('--verify')) { $url = 'http://www.madebymonsieur.com/ostatus_discovery/magic_env/validate/'; echo "== Testing remote verification ==\n\n"; print "Sending for verification to {$url} ...\n"; $client = new HTTPClient(); $response = $client->post($url, array(), array('magic_env' => $envelope)); print $response->getStatus() . "\n\n"; print $response->getBody() . "\n\n"; } if (have_option('--slap')) { $url = get_option_value('--slap'); echo "== Remote salmon slap ==\n\n"; print "Sending signed Salmon slap to {$url} ...\n"; $ok = $salmon->post($url, $entry, $profile); if ($ok) { print "OK\n\n"; } else { print "FAIL\n\n"; } }