Esempio n. 1
0
 public function update()
 {
     $result = false;
     $document = new \DOMDocument();
     if (@$document->loadHTML(mb_convert_encoding(\common\request($this->l_url), "HTML-ENTITIES", "UTF-8"))) {
         $xpath = new \DOMXPath($document);
         $default = new \StdClass();
         if ($meta = $xpath->query("//*//meta[@name='title' or @name='description' or @name='keywords']")) {
             foreach ($meta as $value) {
                 $default->{(string) $value->getAttribute("name")} = (string) $value->getAttribute("content");
             }
         }
         $opengraph = new \StdClass();
         if ($meta = $xpath->query("//*//meta[starts-with(@property, 'og:')]")) {
             foreach ($meta as $value) {
                 $opengraph->{substr($value->getAttribute("property"), 3)} = (string) $value->getAttribute("content");
             }
         }
         $this->l_title = isset($opengraph->title) ? $opengraph->title : (isset($default->title) ? $default->title : null);
         $this->l_description = isset($opengraph->description) ? $opengraph->description : (isset($default->description) ? $default->description : null);
         $this->l_keywords = array();
         if (isset($default->keywords)) {
             foreach (explode($default->keywords, ",") as $keyword) {
                 $this->l_keywords = trim($keyword);
             }
         }
         $this->l_image = isset($opengraph->image) ? $opengraph->image : null;
         $this->l_social->update(true);
         $result = true;
     }
     return $this->l_loadFromFeed() || $result;
 }
Esempio n. 2
0
 public function update($_reload = false)
 {
     $result = false;
     if ($this->owner) {
         if (($_reload || $this->u_vk === null) && ($data = \common\request("https://vk.com/share.php?act=count&index=1&url=" . $this->l_url . "&format=json"))) {
             $matches = null;
             if (preg_match('/^VK\\.Share\\.count\\(\\d+, (\\d+)\\);$/', $data, $matches)) {
                 $this->u_vk = (int) $matches[1];
                 $result = true;
             }
         }
         if (($_reload || $this->u_facebook === null) && ($data = \common\request("http://graph.facebook.com/?ids=" . $this->l_url))) {
             $response = json_decode($data);
             $this->u_facebook = (int) $response->{$this->l_url}->shares;
             $result = true;
         }
         if (($_reload || $this->u_twitter === null) && ($data = \common\request("http://urls.api.twitter.com/1/urls/count.json?url=" . $this->l_url))) {
             $response = json_decode($data);
             $this->u_twitter = (int) $response->count;
             $result = true;
         }
         if (($_reload || $this->u_gplus === null) && ($data = \common\request("https://clients6.google.com/rpc", '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $this->l_url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]', array("Content-type: application/json")))) {
             $response = json_decode($data);
             $this->u_gplus = (int) $response[0]->result->metadata->globalCounts->count;
             $result = true;
         }
     }
     return $result;
 }
Esempio n. 3
0
 private function l_search($_domain)
 {
     if (($response = json_decode(\common\request("http://ajax.googleapis.com/ajax/services/feed/find?v=1.0&q=" . $_domain))) && $response->responseData->entries) {
         foreach ($response->responseData->entries as $entry) {
             if (preg_match('/^https?\\:\\/\\/[^\\/]*?\\.?' . $_domain . '/', $entry->url)) {
                 $this->fetch($entry->url);
             }
         }
         return true;
     }
     return false;
 }