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


PHP HttpRequest::setQueryData方法代码示例

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


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

示例1: Login

        public function Login()
        {
            $signature = $this->SignMessage("frob", $this->Frob, "perms", "delete");
            $query = "api_key={$this->ApiKey}&perms=delete&frob={$this->Frob}&api_sig={$signature}";
            
            $request = new HttpRequest("http://flickr.com/services/auth/", HTTP_METH_GET);
            $request->setQueryData($query);
            $request->enableCookies();
            
            
            $request->setOptions(array(    "redirect" => 10, 
		                                   "useragent" => "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
		                              )
		                        );
            
            $request->send();
            
            var_dump($request->getResponseCode());
            print_r($request->getResponseBody());
            var_dump($request->getResponseStatus());
        }
开发者ID:rchicoria,项目名称:epp-drs,代码行数:21,代码来源:class.Flickr.php

示例2: doDelete

 protected function doDelete($action, array $data)
 {
     $module = empty($action) ? substr($this->module, 0, -1) : $this->module;
     if (strrpos($action, '.json') === false) {
         $action .= '.json';
     }
     array_walk_recursive($data, 'Lupin_Model_API::encode');
     $url = $this->hostname . $module . $action;
     $request = new HttpRequest($url, HTTP_METH_DELETE);
     $request->setQueryData($data);
     try {
         $request->send();
     } catch (Exception $e) {
         return false;
     }
     $this->responseCode = $request->getResponseCode();
     if ($request->getResponseCode() !== 200) {
         return false;
     }
     return $request->getResponseHeader();
 }
开发者ID:jeremykendall,项目名称:spaz-api,代码行数:21,代码来源:API.php

示例3: testAction

 /**
  * Test an action
  *
  * This is the test action method. It test a specific action.
  *
  * @return void
  */
 public function testAction()
 {
     $this->_helper->viewRenderer->setViewSuffix('txt');
     // The options we are accepting for adding
     $options = new Zend_Console_Getopt(array('name|n=s' => 'Name of the action to call.', 'parameters|p=s' => 'Paramters to use. For example var1=val1&var2=val2', 'format|f=s' => 'Format to return. Defaults to XML.', 'method|m=s' => 'Method to use. Defaults to GET.', 'email|e=s' => 'Email or username to use.', 'secretkey|sk=s' => 'Secret key associated with email passed.', 'domain|d=s' => 'Domain to use, if not included will use default', 'query-uri|u=s' => 'Query uri to use. For example /testing/1', 'https|h' => 'Use https.'));
     try {
         $options->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         $this->view->message = $e->getUsageMessage();
         return;
     }
     if ($options->name == '') {
         $this->view->message = $options->getUsageMessage();
         return;
     }
     $confModel = new Default_Model_Configuration();
     if (!$confModel->getKey('api_url')) {
         $this->view->message = 'Remember you can set the default API domain name in your admin configuration.' . PHP_EOL;
     }
     if (!class_exists('HttpRequest')) {
         $this->view->message = 'HttpRequest class was not found the pecl_http (http://pecl.php.net/package/pecl_http) package is required to use the tester.' . PHP_EOL;
         return;
     }
     $action_name = $options->name;
     $params = $options->parameters;
     $format = $options->format;
     $method = $options->method;
     $email = $options->email;
     $password = $options->secretkey;
     $url = $options->domain;
     $ssl = $options->https;
     $query_uri = $options->getOption('query-uri');
     if ($url == '') {
         $url = $confModel->getKey('api_url');
     }
     if ($query_uri == '') {
         $actionModel = new Default_Model_Action();
         $actions = $actionModel->getAll();
         foreach ($actions as $action_details) {
             if ($action_details['name'] == $action_name) {
                 $query_uri = $action_details['route'];
             }
         }
     }
     $newMethod = HTTP_METH_GET;
     switch (strtolower($method)) {
         case 'get':
             $newMethod = HTTP_METH_GET;
             break;
         case 'post':
             $newMethod = HTTP_METH_POST;
             break;
         case 'put':
             $newMethod = HTTP_METH_PUT;
             break;
         case 'delete':
             $newMethod = HTTP_METH_DELETE;
             break;
         case 'head':
             $newMethod = HTTP_METH_HEAD;
             break;
     }
     $request_url = 'http' . ($ssl !== null ? 's' : '') . '://' . $url . '/' . $query_uri . '.' . strtolower($format);
     $httpOptions = array();
     if ($email && $password) {
         $httpOptions = array('headers' => array('Accept' => '*/*'), 'httpauth' => $email . ':' . $password, 'httpauthtype' => HTTP_AUTH_DIGEST);
     }
     $request = new HttpRequest($request_url, $newMethod, $httpOptions);
     if ("POST" == strtoupper($method)) {
         $request->setBody($params);
     } else {
         $request->setQueryData($params);
     }
     $res = $request->send();
     $responseInfo = $request->getResponseInfo();
     $this->view->request_url = $responseInfo['effective_url'];
     $this->view->response_header = $this->collapseHeaders($res->getHeaders());
     $this->view->content = $res->getBody();
     $this->view->status = $res->getResponseCode();
     $this->view->method = isset($method) ? strtoupper($method) : 'GET';
     $this->view->request_post_fields = $newMethod == HTTP_METH_POST ? $params : '';
 }
开发者ID:crlang44,项目名称:frapi,代码行数:89,代码来源:ActionController.php

示例4: HttpRequest

<?php

$r = new HttpRequest('http://www.google.com/search');
// store Googles cookies in a dedicated file
touch('google.txt');
$r->setOptions(array('cookiestore' => 'google.txt'));
$r->setQueryData(array('q' => '+"pecl_http" -msg -cvs -list', 'hl' => 'de'));
// HttpRequest::send() returns an HttpMessage object
// of type HttpMessage::RESPONSE or throws an exception
try {
    print $r->send()->getBody();
} catch (HttpException $e) {
    print $e;
}
开发者ID:cheeepsan,项目名称:pear-core,代码行数:14,代码来源:GET_Queries.php

示例5: waitIfNeeded

 $job->Recipients[$i]->attempts++;
 if ($job->Recipients[$i]->attempts > SMS_MAX_ATTEMPTS_PER_RECIPIENT) {
     waitIfNeeded($start);
     continue;
 }
 // Rotate, round-robin style, through the available sender numbers
 $senderNumber = $numbers[$iterations % count($numbers)];
 // Apply template values to the message, if any
 $nameArray = explode(" ", trim($recipName));
 if (!$nameArray || count($nameArray) == 0 || !trim($nameArray[0])) {
     $nameArray = array($recipName);
 }
 $message = str_replace("{FIRSTNAME}", trim($nameArray[0]), $job->Message);
 // Set up the query's parameters
 $query = array("api_key" => SMS_API_KEY, "api_secret" => SMS_API_SECRET, "from" => $senderNumber, "to" => $recipPhone, "text" => $message);
 $request->setQueryData($query);
 // Send the text message
 $request->send();
 $response = json_decode($request->getResponseBody());
 if (!$job->SegmentCount) {
     $job->SegmentCount = $response->{'message-count'};
 }
 // Each segment in the response contains its own cost and potentially an error code
 foreach ($response->messages as $segment) {
     if ($segment->status == 0) {
         // Successful send.
         // Convert cost from EUR to USD (https://getsatisfaction.com/nexmo/topics/is_the_message_price_thats_returned_from_a_rest_request_in_eur_or_usd)
         $job->Cost += $segment->{'message-price'} * $euroToUsd;
     } else {
         // Problem sending.
         // Status codes available at: https://docs.nexmo.com/index.php/messaging-sms-api/send-message
开发者ID:bluegate010,项目名称:ysaward,代码行数:31,代码来源:sendsms.php

示例6: HttpRequest

<?php

$request = new HttpRequest();
$request->setUrl('http://mockbin.com/har');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array('foo' => array('bar', 'baz'), 'baz' => 'abc', 'key' => 'value'));
try {
    $response = $request->send();
    echo $response->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
开发者ID:lttlrck,项目名称:httpsnippet,代码行数:12,代码来源:query.php


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