protected function getService() { $credentials = $this->getWebmastertoolsCredentials(); $client = Zend_Gdata_ClientLogin::getHttpClient($credentials["username"], $credentials["password"], "sitemaps", Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient")); $service = new Zend_Gdata_Analytics($client); return $service; }
protected function getService() { $credentials = $this->getAnalyticsCredentials(); $client = Zend_Gdata_ClientLogin::getHttpClient($credentials["username"], $credentials["password"], Zend_Gdata_Analytics::AUTH_SERVICE_NAME, Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient")); $service = new Zend_Gdata_Analytics($client, "pimcore-open-source-CMS-framework"); return $service; }
public function getWebmastertoolsSitesAction() { $credentials = $this->getWebmastertoolsCredentials(); if ($credentials) { $username = $credentials["username"]; $password = $credentials["password"]; } if ($this->_getParam("username") && $this->_getParam("password")) { $username = $this->_getParam("username"); $password = $this->_getParam("password"); } try { $client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, "sitemaps", Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient")); $service = new Zend_Gdata($client); $data = $service->getFeed("https://www.google.com/webmasters/tools/feeds/sites/"); foreach ($data->getEntry() as $e) { $verification = ""; // get verification filename foreach ($e->getExtensionElements() as $d) { $a = $d->getExtensionAttributes(); if ($a["type"]["value"] == "htmlpage") { $verification = $d->getText(); break; } } $sites[] = array("profile" => (string) $e->getTitle(), "verification" => $verification); } $this->_helper->json(array("data" => $sites)); } catch (Exception $e) { $this->_helper->json(false); } }
protected function getService() { $credentials = $this->getAnalyticsCredentials(); if (!$this->gdclient) { $this->gdclient = Zend_Gdata_ClientLogin::getHttpClient($credentials["username"], $credentials["password"], Zend_Gdata_Analytics::AUTH_SERVICE_NAME, Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient")); } $service = new Zend_Gdata_Analytics($this->gdclient); return $service; }
public static function upload($asset) { try { $credentials = Asset_Video_Youtube::getYoutubeCredentials(); if (!$credentials) { return; } $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $credentials["username"], $password = $credentials["password"], $service = 'youtube', $client = Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"), $source = 'Pimcore', $loginToken = null, $loginCaptcha = null, 'https://www.google.com/youtube/accounts/ClientLogin'); $httpClient->setConfig(array("timeout" => 3600)); $apikey = $credentials["apiKey"]; $httpClient->setHeaders('X-GData-Key', "key={$apikey}"); $yt = new Zend_Gdata_YouTube($httpClient); $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); $filesource = $yt->newMediaFileSource($asset->getFileSystemPath()); $filesource->setContentType($asset->getMimetype()); $filesource->setSlug($asset->getFilename()); $myVideoEntry->setMediaSource($filesource); $myVideoEntry->setVideoTitle($asset->getFullPath()); $myVideoEntry->setVideoDescription($asset->getFullPath()); $myVideoEntry->setVideoCategory('Comedy'); // Set keywords, note that this must be a comma separated string // and that each keyword cannot contain whitespace $myVideoEntry->SetVideoTags('---, ---'); // Optionally set some developer tags $myVideoEntry->setVideoDeveloperTags(array('mydevelopertag', 'anotherdevelopertag')); // Upload URI for the currently authenticated user $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads'; try { $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry'); $asset->setCustomSetting("youtube", array("id" => strval($newEntry->getVideoId()))); $asset->save(); return true; } catch (Exception $e) { $asset->setCustomSetting("youtube", array("failed" => true)); $asset->save(); } } catch (Exception $e) { Logger::error($e); } return false; }
/** * @return void */ public function continueWithFoundLinks() { //reset DB in case this is executed in a forked child process $this->db = Pimcore_Resource_Mysql::reset(); try { $row = $this->db->fetchRow("SELECT * FROM plugin_searchphp_frontend_crawler_todo ORDER BY id", array()); $nextLink = $row['uri']; $depth = $row['depth']; $cookieJar = unserialize($row['cookiejar']); } catch (Exception $e) { // probably table was already removed because crawler is finished logger::log(get_class($this) . ": Could not extract next link from table plugin_searchphp_frontend_crawler_todo ", Zend_Log::DEBUG); return; } if (empty($nextLink)) { return; } $client = Pimcore_Tool::getHttpClient(); $client->setUri($nextLink); $client->setConfig(array('maxredirects' => $this->maxRedirects, 'keepalive' => true, 'timeout' => $this->timeout)); $client->setCookieJar($cookieJar); $client->setHeaders('If-Modified-Since', null); while ($nextLink) { try { $this->db->delete("plugin_searchphp_frontend_crawler_todo", "id = '" . md5($nextLink) . "'"); } catch (Exception $e) { logger::warn(get_class($this) . ": Could not delete from plugin_searchphp_frontend_crawler_todo - maybe forcing crawler stop right now?"); } if ($depth <= $this->maxLinkDepth) { logger::debug(get_class($this) . ": Link depth [ {$depth} ]"); try { $nextLink = $this->addEvictOutputFilterParameter($nextLink); $client->setUri($nextLink); $client->setCookieJar($cookieJar); $client->setHeaders('If-Modified-Since', null); try { $response = $client->request(); } catch (Zend_Http_Client_Adapter_Exception $e) { logger::log(get_class($this) . ": Could not get response for Link [ {$nextLink} ] ", Zend_Log::ERR); } if ($response instanceof Zend_Http_Response and ($response->isSuccessful() or $response->isRedirect())) { //we don't use port - crawler ist limited to standard port 80 $client->getUri()->setPort(null); //update url - maybe we were redirected $nextLink = $client->getUri(true); $nextLink = $this->removeOutputFilterParameters($nextLink); $valid = $this->validateLink($nextLink); if ($valid) { //see if we were redirected to a place we already have in fetch list or done try { $rowTodo = $this->db->fetchRow("SELECT count(*) as count from plugin_searchphp_frontend_crawler_todo WHERE id ='" . md5($nextLink) . "'"); } catch (Exception $e) { logger::log(get_class($this) . ": could not fetch from plugin_searchphp_contents_temp", Zend_Log::DEBUG); } try { $rowDone = $this->db->fetchRow("SELECT count(*) as count from plugin_searchphp_contents_temp WHERE id ='" . md5($nextLink) . "'"); } catch (Exception $e) { logger::log(get_class($this) . ": could not fetch from plugin_searchphp_contents_temp", Zend_Log::DEBUG); } try { $rowNoIndex = $this->db->fetchRow("SELECT count(*) as count from plugin_searchphp_frontend_crawler_noindex WHERE id ='" . md5($nextLink) . "'"); } catch (Exception $e) { logger::log(get_class($this) . ": could not fetch from plugin_searchphp_frontend_crawler_noindex", Zend_Log::DEBUG); } if ($rowTodo['count'] > 0 or $rowDone['count'] > 0 or $rowNoIndex['count'] > 0) { logger::log(get_class($this) . " Redirected to uri [ {$nextLink} ] - which has already been processed", Zend_Log::DEBUG); } else { try { $success = $this->parse($nextLink, $response, $client->getUri()->getHost(), $client->getCookieJar(), $depth); logger::log(get_class($this) . ": parsed [ {$nextLink} ] ", Zend_Log::DEBUG); } catch (Exception $e) { logger::log($e, Zend_Log::ERR); } } } else { logger::log("We were redirected to an invalid Link [ {$nextLink}]", Zend_Log::DEBUG); } } else { logger::log(get_class($this) . ": Error parsing [ {$nextLink} ] ", Zend_Log::ERR); } } catch (Zend_Uri_Exception $e) { logger::log(get_class($this) . ": Invalid URI [ {$nextLink} ] ", Zend_Log::ERR); } } else { logger::alert(get_class($this) . ": Stopping with uri [ {$nextLink} ] because maximum link depth of [ {$depth} ] has been reached."); } //get next from DB try { $row = $this->db->fetchRow("SELECT * FROM plugin_searchphp_frontend_crawler_todo ORDER BY id", array()); $nextLink = $row['uri']; $depth = $row['depth']; $cookieJar = unserialize($row['cookiejar']); } catch (Exception $e) { //wait 2 seconds then try again sleep(2); try { $row = $this->db->fetchRow("SELECT * FROM plugin_searchphp_frontend_crawler_todo ORDER BY id", array()); $nextLink = $row['uri']; $depth = $row['depth']; $cookieJar = unserialize($row['cookiejar']); } catch (Exception $e) { // probably table was already removed because crawler is finished logger::log(get_class($this) . ": Could not extract next link from table plugin_searchphp_frontend_crawler_todo ", Zend_Log::DEBUG); $nextLink = false; } } } }
public function verifyUploadAction() { $client = Pimcore_Tool::getHttpClient(); $client->setParameterPost("data", base64_encode(Pimcore_Tool_Serialize::serialize(array("id" => $this->_getParam("id"), "type" => $this->_getParam("type"), "token" => Pimcore_Liveconnect::getToken())))); $client->setUri("http://extensions.pimcore.org/share/verifyUpload.php"); $response = $client->request(Zend_Http_Client::POST); $this->_helper->json(array("success" => true)); }