ForkAPI::coreRequestKeys PHP Method

coreRequestKeys() public method

Request public private key-pair
public coreRequestKeys ( string $siteUrl, string $email ) : array
$siteUrl string The URL of the site.
$email string The e-mail adress of the site.
return array
    public function coreRequestKeys($siteUrl, $email)
    {
        trigger_error('The api is deprecated and will be removed in version 5', E_USER_DEPRECATED);
        // build parameters
        $parameters['site_url'] = (string) $siteUrl;
        $parameters['email'] = (string) $email;
        // make the call
        $response = $this->doCall('core.requestKeys', $parameters, false);
        // init var
        $return = array();
        // validate response
        if (!isset($response->keys->public)) {
            throw new ForkAPIException('Invalid XML-response.');
        }
        if (!isset($response->keys->private)) {
            throw new ForkAPIException('Invalid XML-response.');
        }
        // loop services
        $return['public'] = (string) $response->keys->public;
        $return['private'] = (string) $response->keys->private;
        // return
        return $return;
    }

Usage Example

示例#1
0
 /**
  * Store the settings
  */
 private function setSettings()
 {
     // languages settings
     $this->setSetting('core', 'languages', $this->getLanguages(), true);
     $this->setSetting('core', 'active_languages', $this->getLanguages(), true);
     $this->setSetting('core', 'redirect_languages', $this->getLanguages(), true);
     $this->setSetting('core', 'default_language', $this->getVariable('default_language'), true);
     $this->setSetting('core', 'interface_languages', $this->getInterfaceLanguages(), true);
     $this->setSetting('core', 'default_interface_language', $this->getVariable('default_interface_language'), true);
     // other settings
     $this->setSetting('core', 'theme');
     $this->setSetting('core', 'akismet_key', '');
     $this->setSetting('core', 'google_maps_key', '');
     $this->setSetting('core', 'max_num_revisions', 20);
     $this->setSetting('core', 'site_domains', array($this->getVariable('site_domain')));
     $this->setSetting('core', 'site_html_header', '');
     $this->setSetting('core', 'site_html_footer', '');
     // date & time
     $this->setSetting('core', 'date_format_short', 'j.n.Y');
     $this->setSetting('core', 'date_formats_short', array('j/n/Y', 'j-n-Y', 'j.n.Y', 'n/j/Y', 'n/j/Y', 'n/j/Y', 'd/m/Y', 'd-m-Y', 'd.m.Y', 'm/d/Y', 'm-d-Y', 'm.d.Y', 'j/n/y', 'j-n-y', 'j.n.y', 'n/j/y', 'n-j-y', 'n.j.y', 'd/m/y', 'd-m-y', 'd.m.y', 'm/d/y', 'm-d-y', 'm.d.y'));
     $this->setSetting('core', 'date_format_long', 'l j F Y');
     $this->setSetting('core', 'date_formats_long', array('j F Y', 'D j F Y', 'l j F Y', 'j F, Y', 'D j F, Y', 'l j F, Y', 'd F Y', 'd F, Y', 'F j Y', 'D F j Y', 'l F j Y', 'F d, Y', 'D F d, Y', 'l F d, Y'));
     $this->setSetting('core', 'time_format', 'H:i');
     $this->setSetting('core', 'time_formats', array('H:i', 'H:i:s', 'g:i a', 'g:i A'));
     // number formats
     $this->setSetting('core', 'number_format', 'dot_nothing');
     $this->setSetting('core', 'number_formats', array('comma_nothing' => '10000,25', 'dot_nothing' => '10000.25', 'dot_comma' => '10,000.25', 'comma_dot' => '10.000,25', 'dot_space' => '10000.25', 'comma_space' => '10 000,25'));
     // e-mail settings
     $this->setSetting('core', 'mailer_from', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     $this->setSetting('core', 'mailer_to', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     $this->setSetting('core', 'mailer_reply_to', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     // stmp settings
     $this->setSetting('core', 'smtp_server', $this->getVariable('smtp_server'));
     $this->setSetting('core', 'smtp_port', $this->getVariable('smtp_port'));
     $this->setSetting('core', 'smtp_username', $this->getVariable('smtp_username'));
     $this->setSetting('core', 'smtp_password', $this->getVariable('smtp_password'));
     // default titles
     $siteTitles = array('en' => 'My website', 'cn' => '我的网站', 'nl' => 'Mijn website', 'fr' => 'Mon site web', 'de' => 'Meine Webseite', 'hu' => 'Hhonlapom', 'it' => 'Il mio sito web', 'ru' => 'мой сайт', 'es' => 'Mi sitio web');
     // language specific
     foreach ($this->getLanguages() as $language) {
         // set title
         $this->setSetting('core', 'site_title_' . $language, isset($siteTitles[$language]) ? $siteTitles[$language] : $this->getVariable('site_title'));
     }
     /*
      * We're going to try to install the settings for the api.
      */
     require_once PATH_LIBRARY . '/external/fork_api.php';
     // create new instance
     $api = new ForkAPI();
     try {
         // get the keys
         $keys = $api->coreRequestKeys($this->getVariable('site_domain'), $this->getVariable('api_email'));
         // api settings
         $this->setSetting('core', 'fork_api_public_key', $keys['public']);
         $this->setSetting('core', 'fork_api_private_key', $keys['private']);
         // set keys
         $api->setPublicKey($keys['public']);
         $api->setPrivateKey($keys['private']);
         // get services
         $services = (array) $api->pingGetServices();
         // set services
         if (!empty($services)) {
             $this->setSetting('core', 'ping_services', array('services' => $services, 'date' => time()));
         }
     } catch (Exception $e) {
         // we don't need those keys.
     }
     // ckfinder
     $this->setSetting('core', 'ckfinder_license_name', 'Fork CMS');
     $this->setSetting('core', 'ckfinder_license_key', 'QJH2-32UV-6VRM-V6Y7-A91J-W26Z-3F8R');
 }
All Usage Examples Of ForkAPI::coreRequestKeys