Example #1
0
 protected static function getRemotePackageObject($method, $identifier)
 {
     $fh = Loader::helper('file');
     // Retrieve the URL contents
     $dbConfig = \Core::make('config/database');
     $csToken = $dbConfig->get('concrete.marketplace.token');
     $csiURL = urlencode(\Core::getApplicationURL());
     $url = Config::get('concrete.urls.concrete5') . Config::get('concrete.urls.paths.marketplace.item_information');
     $url .= "?" . $method . "=" . $identifier . "&csToken={$csToken}&csiURL=" . $csiURL . "&csiVersion=" . APP_VERSION;
     $json = $fh->getContents($url);
     try {
         // Parse the returned XML file
         $obj = @Loader::helper('json')->decode($json);
         if (is_object($obj)) {
             $mi = new self();
             $mi->setPropertiesFromJSONObject($obj);
             if ($mi->getMarketplaceItemID() > 0) {
                 return $mi;
             }
         }
     } catch (Exception $e) {
         throw new Exception(t('Unable to connect to marketplace to retrieve item'));
     }
 }