当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::auth方法代码示例

本文整理汇总了PHP中Unirest\Request::auth方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::auth方法的具体用法?PHP Request::auth怎么用?PHP Request::auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unirest\Request的用法示例。


在下文中一共展示了Request::auth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: searchContactList

 /**
  * Get list of searched contact list
  * @param  string     $q     Required parameter: Your keyword or query.
  * @return string response from the API call*/
 public function searchContactList($q)
 {
     //check that all required arguments are provided
     if (!isset($q)) {
         throw new \InvalidArgumentException("One or more required arguments were NULL.");
     }
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/search/contacts-lists';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('q' => $q));
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'ClickSendSDK');
     //set HTTP basic auth parameters
     Request::auth(Configuration::$username, Configuration::$key);
     //and invoke the API call request to fetch the response
     $response = Request::get($_queryUrl, $_headers);
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('BAD_REQUEST', 400, $response->body);
     } else {
         if ($response->code == 401) {
             throw new APIException('UNAUTHORIZED', 401, $response->body);
         } else {
             if ($response->code == 403) {
                 throw new APIException('FORBIDDEN', 403, $response->body);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('NOT_FOUND', 404, $response->body);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('METHOD_NOT_FOUND', 405, $response->body);
                     } else {
                         if ($response->code == 429) {
                             throw new APIException('TOO_MANY_REQUESTS', 429, $response->body);
                         } else {
                             if ($response->code == 500) {
                                 throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body);
                             } else {
                                 if ($response->code < 200 || $response->code > 206) {
                                     //[200,206] = HTTP OK
                                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response->body;
 }
开发者ID:clicksend,项目名称:clicksend-php,代码行数:59,代码来源:SearchController.php

示例2: getReferralAccounts

 /**
  * Get all referral accounts
  * @return string response from the API call*/
 public function getReferralAccounts()
 {
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/referral/accounts';
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'ClickSendSDK');
     //set HTTP basic auth parameters
     Request::auth(Configuration::$username, Configuration::$key);
     //and invoke the API call request to fetch the response
     $response = Request::get($_queryUrl, $_headers);
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('BAD_REQUEST', 400, $response->body);
     } else {
         if ($response->code == 401) {
             throw new APIException('UNAUTHORIZED', 401, $response->body);
         } else {
             if ($response->code == 403) {
                 throw new APIException('FORBIDDEN', 403, $response->body);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('NOT_FOUND', 404, $response->body);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('METHOD_NOT_FOUND', 405, $response->body);
                     } else {
                         if ($response->code == 429) {
                             throw new APIException('TOO_MANY_REQUESTS', 429, $response->body);
                         } else {
                             if ($response->code == 500) {
                                 throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body);
                             } else {
                                 if ($response->code < 200 || $response->code > 206) {
                                     //[200,206] = HTTP OK
                                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response->body;
 }
开发者ID:clicksend,项目名称:clicksend-php,代码行数:52,代码来源:ReferralAccountController.php

示例3: setupRequest

 /**
  * @param Request $request
  *
  * @return Request
  */
 public function setupRequest(Request $request)
 {
     $request->auth($this->username, $this->password, $this->method);
     return $request;
 }
开发者ID:artesaos,项目名称:restinga,代码行数:10,代码来源:Basic.php

示例4: updateResellerAccount

 /**
  * Reseller Account
  * @param  string     $clientUserId        Required parameter: Example: 
  * @param  string     $username            Required parameter: Example: 
  * @param  string     $password            Required parameter: Example: 
  * @param  string     $userEmail           Required parameter: Example: 
  * @param  string     $userPhone           Required parameter: Example: 
  * @param  string     $userFirstName       Required parameter: Example: 
  * @param  string     $userLastName        Required parameter: Example: 
  * @param  string     $accountName         Required parameter: Example: 
  * @param  string     $country             Required parameter: Example: 
  * @return string response from the API call*/
 public function updateResellerAccount($clientUserId, $username, $password, $userEmail, $userPhone, $userFirstName, $userLastName, $accountName, $country)
 {
     //check that all required arguments are provided
     if (!isset($clientUserId, $username, $password, $userEmail, $userPhone, $userFirstName, $userLastName, $accountName, $country)) {
         throw new \InvalidArgumentException("One or more required arguments were NULL.");
     }
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/reseller/accounts/{client_user_id}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('client_user_id' => $clientUserId));
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('username' => $username, 'password' => $password, 'user_email' => $userEmail, 'user_phone' => $userPhone, 'user_first_name' => $userFirstName, 'user_last_name' => $userLastName, 'account_name' => $accountName, 'country' => $country));
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'ClickSendSDK');
     //set HTTP basic auth parameters
     Request::auth(Configuration::$username, Configuration::$key);
     //and invoke the API call request to fetch the response
     $response = Request::put($_queryUrl, $_headers);
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('BAD_REQUEST', 400, $response->body);
     } else {
         if ($response->code == 401) {
             throw new APIException('UNAUTHORIZED', 401, $response->body);
         } else {
             if ($response->code == 403) {
                 throw new APIException('FORBIDDEN', 403, $response->body);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('NOT_FOUND', 404, $response->body);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('METHOD_NOT_FOUND', 405, $response->body);
                     } else {
                         if ($response->code == 429) {
                             throw new APIException('TOO_MANY_REQUESTS', 429, $response->body);
                         } else {
                             if ($response->code == 500) {
                                 throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body);
                             } else {
                                 if ($response->code < 200 || $response->code > 206) {
                                     //[200,206] = HTTP OK
                                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response->body;
 }
开发者ID:clicksend,项目名称:clicksend-php,代码行数:69,代码来源:ResellerAccountController.php

示例5: __construct

 /**
  * RazorpayClient constructor.
  * @param $key
  * @param $secret
  */
 public function __construct($key, $secret)
 {
     $this->key = $key;
     $this->secret = $secret;
     Request::auth($this->key, $this->secret);
 }
开发者ID:niranjan94,项目名称:razorpay-client,代码行数:11,代码来源:RazorpayClient.php

示例6: testBasicAuthentication

 public function testBasicAuthentication()
 {
     Request::auth('user', 'password');
     $response = Request::get('http://mockbin.com/request');
     $this->assertEquals('Basic dXNlcjpwYXNzd29yZA==', $response->body->headers->authorization);
 }
开发者ID:RusinovIG,项目名称:unirest-php,代码行数:6,代码来源:RequestTest.php

示例7: updateSubaccount

 /**
  * Update subaccount
  * @param  int             $subaccountId         Required parameter: Example: 
  * @param  string|null     $password             Optional parameter: Example: 
  * @param  string|null     $email                Optional parameter: Example: 
  * @param  string|null     $phoneNumber          Optional parameter: Example: 
  * @param  string|null     $firstName            Optional parameter: Example: 
  * @param  string|null     $lastName             Optional parameter: Example: 
  * @param  bool|null       $accessUsers          Optional parameter: Example: true
  * @param  bool|null       $accessBilling        Optional parameter: Example: true
  * @param  bool|null       $accessReporting      Optional parameter: Example: true
  * @param  bool|null       $accessContacts       Optional parameter: Example: false
  * @param  bool|null       $accessSettings       Optional parameter: Example: true
  * @return string response from the API call*/
 public function updateSubaccount($subaccountId, $password = NULL, $email = NULL, $phoneNumber = NULL, $firstName = NULL, $lastName = NULL, $accessUsers = true, $accessBilling = true, $accessReporting = true, $accessContacts = false, $accessSettings = true)
 {
     //check that all required arguments are provided
     if (!isset($subaccountId)) {
         throw new \InvalidArgumentException("One or more required arguments were NULL.");
     }
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/subaccounts/{subaccount_id}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('subaccount_id' => $subaccountId));
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('password' => $password, 'email' => $email, 'phone_number' => $phoneNumber, 'first_name' => $firstName, 'last_name' => $lastName, 'access_users' => null != $accessUsers ? var_export($accessUsers, true) : true, 'access_billing' => null != $accessBilling ? var_export($accessBilling, true) : true, 'access_reporting' => null != $accessReporting ? var_export($accessReporting, true) : true, 'access_contacts' => null != $accessContacts ? var_export($accessContacts, true) : false, 'access_settings' => null != $accessSettings ? var_export($accessSettings, true) : true));
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'ClickSendSDK');
     //set HTTP basic auth parameters
     Request::auth(Configuration::$username, Configuration::$key);
     //and invoke the API call request to fetch the response
     $response = Request::put($_queryUrl, $_headers);
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('BAD_REQUEST', 400, $response->body);
     } else {
         if ($response->code == 401) {
             throw new APIException('UNAUTHORIZED', 401, $response->body);
         } else {
             if ($response->code == 403) {
                 throw new APIException('FORBIDDEN', 403, $response->body);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('NOT_FOUND', 404, $response->body);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('METHOD_NOT_FOUND', 405, $response->body);
                     } else {
                         if ($response->code == 429) {
                             throw new APIException('TOO_MANY_REQUESTS', 429, $response->body);
                         } else {
                             if ($response->code == 500) {
                                 throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body);
                             } else {
                                 if ($response->code < 200 || $response->code > 206) {
                                     //[200,206] = HTTP OK
                                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response->body;
 }
开发者ID:clicksend,项目名称:clicksend-php,代码行数:71,代码来源:SubaccountController.php


注:本文中的Unirest\Request::auth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。