/** * 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")); } } }
public function executeCheck_endpoint(sfWebRequest $request) { $this->getResponse()->setContentType('application/json'); $lUrl = $request->getParameter('ep-url'); $lHostId = $request->getParameter('host_id'); $lDomainProfile = Doctrine::getTable('DomainProfile')->find($lHostId); $lVerified = PubSubHubbub::verifyCallback($lDomainProfile->getDomain(), $lUrl); $lReturn = array(); if ($lVerified === true) { $lEndpoint = new DomainSubscriptions(); $lEndpoint->setDomainProfileId($lDomainProfile->getId()); $lEndpoint->setCallback($lUrl); $lEndpoint->save(); $lReturn['success'] = true; $lReturn['row'] = $this->getPartial('domain_profiles/domain_profiles_row_content', array('domain_profile' => $lDomainProfile, 'pHasError' => false)); $lReturn['host_id'] = $lDomainProfile->getId(); } else { $lReturn['success'] = false; $lReturn['msg'] = _('The Endpoint is not correct. Please check the url or your implementation. For more info read our <a href="http://code.google.com/p/spreadly/wiki/PuSH_API" target="_blank">api documentation</a>'); } return $this->renderText(json_encode($lReturn)); }