Beispiel #1
0
 private function getUploadUrl($url_endpoint)
 {
     $headers = $this->getAuth()->getAuthorizationHeader();
     $answer = WixHttpUtils::curl($url_endpoint, $headers);
     if ($answer['http_code'] === 200) {
         return json_decode($answer['result'])->upload_url;
     } else {
         return;
     }
 }
 public function createToken()
 {
     $mct = explode(" ", microtime());
     $headers = array('x-wix-auth-nonce' => bin2hex(openssl_random_pseudo_bytes(6)), 'x-wix-auth-ts' => date("Y-m-d\\TH:i:s", $mct[1]) . substr((string) $mct[0], 1, 4) . 'Z');
     ksort($headers);
     $canonicalized = $this->canonicalizeParams($headers);
     $signed_hmac = $this->signString($canonicalized, $this->secret);
     $signed_web_safe = $this->base64url_encode($signed_hmac);
     $auth_header = sprintf("%s %s:%s", 'WIX', $this->api_key, $signed_web_safe);
     $headers['Authorization'] = $auth_header;
     $answer = WixHttpUtils::curl($this->auth_url, $headers);
     if ($answer['http_code'] === 200) {
         $response = json_decode($answer['result']);
         $this->auth_scheme = $response->scheme;
         $this->token = $response->token;
         return $this->token;
     }
     // echo '<pre>'.print_r($canonicalized, true).'</pre>';
     // echo '<pre>'.print_r($auth_header, true).'</pre>';
     // echo '<pre>'.print_r($answer, true).'</pre>';
 }