public function findKeys($entity) { $search_terms = $entity->nameSearch() . " site:twitter.com"; $goog = new LsGoogle(); $goog->setQuery($search_terms); $results = $goog->execute(); $results = $goog->parseSearchResults($results); $matches = array(); if ($results) { foreach ($results as $r) { $match = array(); $url = $r['unescapedUrl']; if (preg_match('/(.+?)\\(.*?\\)\\s+on\\s+Twitter$/is', $r['titleNoFormatting'], $m_name)) { $match['name'] = trim($m_name[1]); if (preg_match('/twitter.com\\/(\\#\\/)?([^\\/]+)$/is', $url, $m)) { $match['id'] = $m[2]; $matches[] = $match; } } } } return $matches; }
public function checkBoardPage($board_rels) { $goog = new LsGoogle(); $goog->setQuery($this->entity->name . " board"); $results = $goog->execute(); $results = $goog->parseSearchResults($results); if (count($results)) { $url = $results[0]['unescapedUrl']; if (stripos($url, "yahoo.com")) { $url = $results[1]['unescapedUrl']; } $this->printDebug($url); try { if (!$this->browser->get($url)->responseIsError()) { $text = $this->browser->getResponseText(); $text = LsHtml::replaceEntities($text); $status_arr = array(); $unique_arr = array(); foreach ($board_rels as $br) { $found = 0; //$this->printDebug($br->Entity1->getNameRegex()); $regexes = $br->Entity1->getNameRegexes(); foreach ($regexes as $regex) { if (preg_match_all($regex, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { //var_dump($matches); $found = 1; if (!in_array($br->entity1_id, $unique_arr)) { $unique_arr[] = $br->entity1_id; } break; } } $status_arr[] = $found; $this->printDebug($br->Entity1->name . " > " . $found); } if (count($unique_arr) > 1) { $this->printDebug("\tenough board member names found to mark as current or not"); for ($i = 0; $i < count($status_arr); $i++) { $br = $board_rels[$i]; if ($status_arr[$i] == 1) { $br->is_current = 1; } else { $br->is_current = 0; } if (!$this->testMode) { $br->save(); $br->addReference($url, null, null, $this->entity->name . ' board', null, null); } } return 1; } else { return 0; } } } catch (Exception $e) { return 0; } } else { return -1; } }