Пример #1
0
 /**
  * Retrieves read and write nonce tokens from the warehouse.
  * @param string $website_id Indicia ID for the website.
  * @param string $password Indicia password for the website.
  * @return Returns an array containing:
  * 'read' => the read authorisation array,
  * 'write' => the write authorisation input controls to insert into your form.
  * 'write_tokens' => the write authorisation array, if needed as separate tokens rather than just placing in form.
  */
 public static function get_read_write_auth($website_id, $password)
 {
     self::$website_id = $website_id;
     /* Store this for use with data caching */
     $postargs = "website_id={$website_id}";
     $response = self::http_post(parent::$base_url . 'index.php/services/security/get_read_write_nonces', $postargs);
     $nonces = json_decode($response['output'], true);
     $write = '<input id="auth_token" name="auth_token" type="hidden" class="hidden" ' . 'value="' . sha1($nonces['write'] . ':' . $password) . '" />' . "\r\n";
     $write .= '<input id="nonce" name="nonce" type="hidden" class="hidden" ' . 'value="' . $nonces['write'] . '" />' . "\r\n";
     return array('write' => $write, 'read' => array('auth_token' => sha1($nonces['read'] . ':' . $password), 'nonce' => $nonces['read']), 'write_tokens' => array('auth_token' => sha1($nonces['write'] . ':' . $password), 'nonce' => $nonces['write']));
 }