_server/opengraph.php
/**
   * Fetches a URI and parses it for Open Graph data, returns
   * false on error.
   *
   * @param $URI    URI to page to parse for Open Graph data
   * @return OpenGraph
   */
Fetches a URI and parses it for Open Graph data, returns
false on error.

@param $URI    URI to page to parse for Open Graph data
@return OpenGraph
Fetches a URI and parses it for Open Graph data returns false on error . @param $URI URI to page to parse for Open Graph data @return OpenGraph
static public function fetch($URI) {
      try {
          $curl = curl_init($URI);
          if ($curl === false) {
              throw new Exception('failed to initialize');
          }
          curl_setopt($curl, CURLOPT_FAILONERROR, true);
          curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
          curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($curl, CURLOPT_TIMEOUT, 15);
          curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
          curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
          curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
          $response = curl_exec($curl);
          if ($response === false) {
              throw new Exception(curl_error($curl), curl_errno($curl));
          }
          curl_close($curl);
          if (!empty($response)) {
              $return["status"] = "success";
              $return["code"] = 0;
              $return["string"] = "see result";
              $return["result"] = self::_parse($response, $URI);
              return $return;
          } else {
              $return["status"] = "error";
              $return["code"] = 1;
              $return["string"] = "Error: Empty result";
              $return["result"] = false;
              return $return;
          }
      } catch (Exception $e) {
          $return["status"] = "error";
          $return["code"] = 1;
          $return["string"] = sprintf(
              'Curl failed with error #%d: %s',
              $e->getCode(), $e->getMessage());
          $return["result"] = false;
          return $return;
      }
  }
static public function fetch ( $ URI ) { try { $ curl = curl_init ( $ URI ) ; if ( $ curl === false ) { throw new Exception ( 'failed to initialize' ) ; } curl_setopt ( $ curl , CURLOPT_FAILONERROR , true ) ; curl_setopt ( $ curl , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_TIMEOUT , 15 ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYHOST , false ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ curl , CURLOPT_USERAGENT , $ _SERVER [ 'HTTP_USER_AGENT' ] ) ; $ response = curl_exec ( $ curl ) ; if ( $ response === false ) { throw new Exception ( curl_error ( $ curl ) , curl_errno ( $ curl ) ) ; } curl_close ( $ curl ) ; if ( ! empty ( $ response ) ) { $ return [ " status " ] = " success " ; $ return [ " code " ] = 0 ; $ return [ " string " ] = " see result " ; $ return [ " result " ] = self :: _parse ( $ response , $ URI ) ; return $ return ; } else { $ return [ " status " ] = " error " ; $ return [ " code " ] = 1 ; $ return [ " string " ] = " Error: Empty result " ; $ return [ " result " ] = false ; return $ return ; } } catch ( Exception $ e ) { $ return [ " status " ] = " error " ; $ return [ " code " ] = 1 ; $ return [ " string " ] = sprintf ( 'Curl failed with error #%d: %s' , $ e -> getCode ( ) , $ e -> getMessage ( ) ) ; $ return [ " result " ] = false ; return $ return ; } }
Fetches a URI and parses it for Open Graph data, returns
 false on error.
Fetches a URI and parses it for Open Graph data returns false on error .