Gets the number of share of the given URL on the given provider.

@param string $providerName
@param string $url
@param bool   $delayUpdate

@throws \RuntimeException

@return int
501792
public function getShares($providerName, $url, $delayUpdate = false)
    {
        $this->checkProvider($providerName);

        $id = $this->getId($providerName, $url);
        $lifeTime = $this->providers[$providerName]['lifeTime'];
        $now = new \DateTime();

        $dataFromCache = $this->cache->fetch($id);
        $shares = isset($dataFromCache[0]) ? $dataFromCache[0] : false;
        $expired = isset($dataFromCache[1]) && $dataFromCache[1]->add($lifeTime) < $now;

        if (!$delayUpdate && (false === $shares || $expired)) {
            $shares = $this->providers[$providerName]['provider']->getShares($url);

            $this->cache->save($id, array($shares, $now));
        } else {
            if ($delayUpdate && (false === $shares || $expired)) {
                $this->toUpdate[$providerName][] = $url;
            }

            $shares = intval($shares);
        }

        return $shares;
    }
456050
public function shortenUrl($url, $provider)
    {
        if (!empty($url) && !empty($provider)) {
            if ($provider == 'tinyurl') {
                $url_data = sprintf($this->_tinyUrlShortApiUrl, $url);
            } elseif ($provider == 'google') {
                $url_data = sprintf('%s/url', $this->_googleShortApiUrl);
            }

            switch ($provider) {
                case 'tinyurl':
                    $ch = curl_init($url_data);  
                    $timeout = 5;  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
                    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);  
                    $result = curl_exec($ch);  
                    curl_close($ch);

                    return $result; 
                    break;

                case 'google':
                    $ch = curl_init($url_data);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    $requestData = array(
                        'longUrl' => $url
                    );

                    curl_setopt($ch, CURLOPT_POST, true);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData));
                    $result = json_decode(curl_exec($ch), true);
                    curl_close($ch);

                    return $result['id'];
                    break;
                
                default:
                    return false;
                    break;
            }
        }
        return false;
    }
379599
public function shared(string $name, ...$args)
    {
        if (!isset(self::$share[$name])) {
            self::$share[$name] = $this->resolve($name, ...$args);
        }

        return self::$share[$name];
    }
385412
private function cacheOrFetchResult($url)
    {
        if ($this->cache !== false) {
            /** @var AbstractCache $cache */
            $cache = $this->cache;
            $cache->setSeconds($this->seconds);
            if ($cache->isCached($url)) {
                $this->wasCached = true;
                return $cache->getCached($url);
            }
            $result = $this->fetcher->fetch($url);
            $cache->setCached($url, $result);
        } else {
            $result = $this->fetcher->fetch($url);
        }
        $this->wasCached = false;

        return $result;
    }
65091
public function share_url($url){
        if (empty($url)){
            if ($this->business_interface)$this->business_interface->log('share_url url is null');
            return null;
        }
        $js_api_ticket = $this->get_js_api_ticket();
        if (empty($js_api_ticket)){
            if ($this->business_interface)$this->business_interface->log('share_url js_api_ticket is null');
            return null;
        }
        $timestamp = time();
        $nonce_str = $this->get_nonce_Str(16);

        $str = "jsapi_ticket=$js_api_ticket&noncestr=$nonce_str&timestamp=$timestamp&url=$url";
        $signature = sha1($str);
        $sign_package = [
            'app_id'=>$this->config['app_id'],
            'nonce_str'=>$nonce_str,
            'timestamp'=>$timestamp,
            'url'=>$url,
            'signature'=>$signature,
            'raw_string'=>$str,
        ];
        return $sign_package;
    }
1553
@Override
    public List<ProviderAccount> listProviderAccounts(String url,
                                               String username,
                                               String password) {
        return duraCloudDao.listProviderAccounts(url, username, password);
    }
880757
public function setDelay($delay)
    {
        if (is_string($delay) && ctype_digit($delay)) {
            $delay = (int) $delay;
        } elseif (!is_int($delay)) {
            throw new \RuntimeException('Delay should be an integer in MS.');
        }

        $this->delay = $delay;

        return $this;
    }
985786
public function setShareResult($b) {
        if ($this->isStarted) {
            throw new Exception\RuntimeException('Invalid timeout value');
        }
        $this->shareResult = $b;
        return $this;
    }
982348
public static function setLastVisitedUrl($url){
	    if(empty($url)){
	        throw new common_Exception('Cannot register an empty URL for the last visited extension');
	    }
        $success = false;
	    
	    $userUri = common_session_SessionManager::getSession()->getUserUri();
	    if (!empty($userUri)) {
	        $user = new \core_kernel_classes_Resource($userUri);
    	    $user = new core_kernel_classes_Resource($userUri);
    	    if ($user->exists()) {
    	        // user in ontology
    	        
    	        //clean up what's stored
    	        $url = str_replace(ROOT_URL, '', $url);
    	        $success = $user->editPropertyValues(new core_kernel_classes_Property(TaoOntology::PROPERTY_USER_LAST_EXTENSION), $url);
    	    } // else we fail;
	    }
	    return $success;
	}
535134
public function request($url, array $params = array())
    {
        if (false === $provider = $this->resolver->resolve($url, $params)) {
            throw new \RuntimeException();
        }

        return $provider->request($url, $params);
    }
290447
public static function getVKontakteShares($url = false)
    {
        $url     = parent::getUrl($url);
        $dataUrl = sprintf(Config\Services::VKONTAKTE_INFO_URL, urlencode($url));

        $htmlData = parent::_getPage($dataUrl);
        @preg_match_all('#^VK\.Share\.count\(1, (\d+)\);$#si', $htmlData, $matches);

        return isset($matches[1][0]) ? intval($matches[1][0]) : parent::noDataDefaultValue();
    }
357064
protected function prepareUrl($url)
    {
        if (empty($url)) {
            throw new \RuntimeException(sprintf('Empty URL at item with id: "%s"', $this->getId()));
        }

        if (stripos($url, '://') !== false) {
            throw new \RuntimeException(sprintf('Malformed relative URL at item with id: "%s"', $this->getId()));
        }

        if (stripos($url, '/') !== 0) {
            throw new \RuntimeException(sprintf('Relative URL must start with "/" at item with id: "%s"', $this->getId()));
        }

        return $url;
    }
95994
public function embed(UriInterface $url, $providerName)
    {
        $adapter = $this->getUrlAdapter($url);
        $providers = $adapter->getProviders();
        if (!isset($providers[$providerName])) {
            return [];
        }
        /** @var \Embed\Providers\Provider $provider */
        $provider = $providers[$providerName];

        return $provider->getBag()->getAll();
    }
103653
public function addViewReplay($name, $url)
    {
        $replayElement = new ViewReplay($name, $url);
        return $this->addElement($replayElement);
    }
454699
public static function getPageAuthority($url = false)
    {
        $data = static::getCols('34359738368', $url);
        return (parent::noDataDefaultValue() == $data) ? $data :
            $data['upa'];
    }
203737
public function getAddTimerCode($name, $delay, $replaceExisting = false) {
        $functionName = $this->getAddTimerFunctionName();
        return $functionName . '("' . $name . '", ' . $delay . ', ' . ($replaceExisting ? 'True' : 'False') . ');';
    }
1090764
public static function early_redirect_message($encodedurl, $message, $delay) {
        $meta = '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />';
        $content = self::early_error_content($message, null, null, null);
        $content .= self::plain_redirect_message($encodedurl);

        return self::plain_page(get_string('redirect'), $content, $meta);
    }