Example #1
0
 /**
  * Create the signature string
  *
  * @param  string $access_key
  * @return string
  */
 public function create($access_key)
 {
     $str = $this->build->getMethod() . "\n";
     $str .= $this->headers['Content-Md5'] . "\n";
     $str .= $this->headers['Content-Type'] . "\n";
     $str .= $this->headers['Date'] . "\n";
     foreach ($this->oss_headers as $k => $v) {
         $str .= $k . ':' . $v . "\n";
     }
     $str .= $this->build->getPath();
     $params = [];
     $overrides = [];
     foreach ($this->params as $k => $v) {
         if (in_array($k, $this->param_keys)) {
             $params[$k] = $v;
         }
     }
     foreach ($this->overrides as $k => $v) {
         if (in_array($k, $this->override_keys)) {
             $overrides[$k] = $v;
         }
     }
     $query = array_merge($params, $overrides);
     $query_str = http_build_query($query);
     if (!empty($query_str)) {
         $query_str = str_replace('acl=', 'acl', $query_str);
         $str .= '?' . $query_str;
     }
     return base64_encode(hash_hmac('sha1', $str, $access_key, true));
 }
Example #2
0
 public function run()
 {
     $request = $this->builder->build();
     try {
         $this->catchErrors($request);
         $response = $this->getResponse($request);
     } catch (\Exception $e) {
         $response = $this->error($request, $e);
     }
     $this->deliverer->deliver($response);
 }
Example #3
0
 public function execute($depth = 0)
 {
     $vkResult = new VkResult();
     if ($depth >= $this->attempts) {
         $vkResult->is_request_error = true;
         return $vkResult;
     }
     if (!$this->params->existsParam("v")) {
         $this->params->set("v", $this->version);
     }
     if ($this->access_token instanceof VkAccessToken) {
         if (!$this->params->existsParam("access_token")) {
             $this->params->set("access_token", $this->access_token->getToken());
         }
     }
     $builder = new RequestBuilder($this->method, $this->params);
     $requestStr = $builder->build();
     $response = $this->http_client->post($requestStr, $this->params->getParams());
     $jsonArray = json_decode($response, true);
     if (json_last_error() != JSON_ERROR_NONE) {
         $vkResult = $this->execute($depth + 1);
     } else {
         if (array_key_exists("response", $jsonArray)) {
             $vkResponse = new VkResponse($jsonArray['response']);
             $vkResult->is_success = true;
             $vkResult->response = $vkResponse;
             if ($this->success_listener) {
                 $listener = $this->success_listener;
                 $listener($vkResponse);
             }
         } else {
             if (array_key_exists("error", $jsonArray)) {
                 if ($jsonArray['error']['error_code'] == 14) {
                     $captcha = new VkCaptcha($jsonArray['error']['captcha_sid'], $jsonArray['error']['captcha_img']);
                     $key = $captcha->getKey();
                     if ($key) {
                         $this->params->set("captcha_sid", $captcha->getSid());
                         $this->params->set("captcha_key", $key);
                         return $this->execute($depth + 1);
                     }
                 }
                 $vkError = new VkError($jsonArray['error']);
                 VkApi::setLastError($vkError);
                 $vkResult->is_error = true;
                 $vkResult->error = $vkError;
                 if ($this->vk_error_listener) {
                     $listener = $this->vk_error_listener;
                     $listener($vkError);
                 }
             }
         }
     }
     return $vkResult;
 }
 function __construct($merchantId, $token, $amount, $baseUrl = KushkiEnvironment::PRODUCTION)
 {
     parent::__construct($merchantId);
     $this->url = $baseUrl . KushkiConstant::CHARGE_URL;
     $this->token = $token;
     $this->amount = $amount;
 }
Example #5
0
 function __construct($merchantId, $ticket, $amount, $baseUrl = KushkiEnvironment::PRODUCTION)
 {
     parent::__construct($merchantId);
     $this->url = $baseUrl . KushkiConstant::VOID_URL;
     $this->amount = $amount;
     $this->ticket = $ticket;
 }
 function __construct($merchantId, $token, $amount, $months, $baseUrl = KushkiEnvironment::PRODUCTION)
 {
     parent::__construct($merchantId);
     $this->url = $baseUrl . KushkiConstant::DEFERRED_URL;
     $this->token = $token;
     $this->amount = $amount;
     $this->months = $months;
 }
Example #7
0
 /**
  * удаляет пользователя по id.
  */
 public function deleteUser($id)
 {
     $sql = new RequestBuilder($this->dbInctance);
     $sql->delete()->from('^table', array('^table' => $this->dbStruct['table']))->where('^id = :val', array('^id' => $this->dbStruct['id'], ':val' => $id));
     if (!$sql->query()->rowCount()) {
         throw new Exception("[" . __CLASS__ . "] Не удалось удалить запись! Возможно, она уже удалена.");
     }
     return new DeleteUser(array('result' => true));
 }
Example #8
0
 private function buildRequest($request)
 {
     $requestBuilder = new RequestBuilder($request);
     return $requestBuilder->build();
 }
Example #9
0
$applicationId = 'trkddemoappwm';
$createTokenRequest = array('ApplicationID' => $applicationId, 'Username' => '*****@*****.**', 'Password' => 't7c9k32db');
//make sure credentials are initialized here
$wsAddressingHeaders = array(new SoapHeader('http://www.w3.org/2005/08/addressing', 'To', 'https://api.rkd.reuters.com/api/2006/05/01/TokenManagement_1.svc/Anonymous'), new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1/CreateServiceToken_1'));
try {
    $createTokenResponse = $client->__soapCall('CreateServiceToken_1', array('parameters' => $createTokenRequest), null, $wsAddressingHeaders);
    echo 'Token received<br/>Token:&nbsp;' . bin2hex($createTokenResponse->Token) . '<br/>Expiration:&nbsp;' . $createTokenResponse->Expiration . '<br/>';
} catch (SoapFault $e) {
    echo "<span style='color:red'>Error occured: " . $e->getMessage() . "</span>";
}
$client2 = new SoapClient("http://api.trkd.thomsonreuters.com/schemas/wsdl/News/News_1_HttpAndRKDToken.wsdl", array('soap_version' => SOAP_1_2, 'trace' => true));
//in order to get the XML response enable trace
$auth = array('ApplicationID' => $applicationId, 'Token' => $createTokenResponse->Token);
//make sure the app ID is initialized here
$authvar = new SoapVar($auth, SOAP_ENC_OBJECT, "AuthorizationType", 'http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1');
$newsRequest = RequestBuilder::createRequest();
$wsAddressingHeaders2 = array(new SoapHeader('http://www.w3.org/2005/08/addressing', 'To', 'http://api.rkd.reuters.com/api/2006/05/01/News_1.svc'), new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://www.reuters.com/ns/2006/05/01/webservices/rkd/News_1/RetrieveStoryML_1'), new SoapHeader('http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1', 'Authorization', $authvar));
try {
    #$tmp['_'] = 'RetrieveStoryML_1';
    $RetrieveStoryML_1['characters'] = "zh-Hans";
    $endcoded = new SoapVar($RetrieveStoryML_1, SOAP_ENC_OBJECT);
    $newsResponse = $client2->__soapCall($endcoded, array('parameters' => $newsRequest), null, $wsAddressingHeaders2);
    #$view = new RetrieveStoryML1Response($newsResponse);
    echo '<hr/><a href="#formatted">Go to formatted ouput.</a>';
    echo '<hr/><h2>XML Response:</h2><br/>' . htmlspecialchars($client2->__getLastResponse());
    //get XML response
    #header("Content-Type: text/html; charset=utf-8");
    #echo '<hr/><h2><a name="formatted">Formatted output:</a></h2><br/>' . $view->getHTML(); //creaing HTML from the response object
} catch (SoapFault $e) {
    echo "<span style='color:red'>Error occured: " . $e->getMessage() . "</span>";
}
Example #10
0
}
#$client = new SoapClient("http://api.rkd.reuters.com/schemas/wsdl/TokenManagement/TokenManagement_1_HttpsAndAnonymous.wsdl", array('soap_version' => SOAP_1_2));
$client = new SoapClient("http://api.trkd.thomsonreuters.com/schemas/wsdl/TokenManagement/TokenManagement_1_HttpsAndAnonymous.wsdl", array('soap_version' => SOAP_1_2));
$applicationId = 'trkddemoappwm';
$createTokenRequest = array('ApplicationID' => $applicationId, 'Username' => '*****@*****.**', 'Password' => 't7c9k32db');
//make sure credentials are initialized here
$wsAddressingHeaders = array(new SoapHeader('http://www.w3.org/2005/08/addressing', 'To', 'https://api.rkd.reuters.com/api/2006/05/01/TokenManagement_1.svc/Anonymous'), new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1/CreateServiceToken_1'));
try {
    $createTokenResponse = $client->__soapCall('CreateServiceToken_1', array('parameters' => $createTokenRequest), null, $wsAddressingHeaders);
    echo 'Token received<br/>Token:&nbsp;' . bin2hex($createTokenResponse->Token) . '<br/>Expiration:&nbsp;' . $createTokenResponse->Expiration . '<br/>';
} catch (SoapFault $e) {
    echo "<span style='color:red'>Error occured: " . $e->getMessage() . "</span>";
}
$client2 = new SoapClient("http://api.trkd.thomsonreuters.com/schemas/wsdl/Quotes/Quotes_1_HttpAndRKDToken.wsdl", array('soap_version' => SOAP_1_2, 'trace' => true));
//in order to get the XML response enable trace
$auth = array('ApplicationID' => $applicationId, 'Token' => $createTokenResponse->Token);
//make sure the app ID is initialized here
$authvar = new SoapVar($auth, SOAP_ENC_OBJECT, "AuthorizationType", 'http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1');
$quotesRequest = RequestBuilder::createRequest();
$wsAddressingHeaders2 = array(new SoapHeader('http://www.w3.org/2005/08/addressing', 'To', 'http://api.rkd.reuters.com/api/2006/05/01/Quotes_1.svc'), new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://www.reuters.com/ns/2006/05/01/webservices/rkd/Quotes_1/RetrieveItem_3'), new SoapHeader('http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1', 'Authorization', $authvar));
try {
    $quotesResponse = $client2->__soapCall('RetrieveItem_3', array('parameters' => $quotesRequest), null, $wsAddressingHeaders2);
    $view = new RetrieveItem3Response($quotesResponse);
    #echo '<hr/><a href="#formatted">Go to formatted ouput.</a>';
    #保存三个值:经济指标,预期值(CF_LAST),前值(CF_CLOSE),公布值(CF_YIELD)
    #echo '<hr/><h2>XML Response:</h2><br/>' . htmlspecialchars($client2->__getLastResponse()); //get XML response
    #echo '<hr/><h2><a name="formatted">Formatted output:</a></h2><br/>' . $view->getHTML(); //creaing HTML from the response object
    print_r($view);
} catch (SoapFault $e) {
    echo "<span style='color:red'>Error occured: " . $e->getMessage() . "</span>";
}
Example #11
0
 /**
  * @return \Mcustiel\Phiremock\Client\Utils\RequestBuilder
  */
 public static function fetchRequest()
 {
     return RequestBuilder::create('fetch');
 }
 /**
  * Retrieves a new token to API authentication
  *
  * @return string
  */
 public function request()
 {
     $requestInfo = ServiceEnum::toEndpoint('requestToken');
     $parameters = ['clientId' => $this->clientId, 'clientSecret' => $this->clientSecret];
     return $this->requestBuilder->request((new UrlBuilder())->build($requestInfo['subdomain'], $requestInfo['action'], $requestInfo['service']), $requestInfo['method'], ['json' => $parameters]);
 }