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


PHP HTTP_Request2::addPostParameter方法代码示例

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


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

示例1: testDefaultPrivacyEdit

 /**
  * Test that the default privacy setting is used when an existing
  * bookmark is updated with edit.php.
  */
 public function testDefaultPrivacyEdit()
 {
     $this->setUnittestConfig(array('defaults' => array('privacy' => 2)));
     list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1');
     $cookies = $req->getCookieJar();
     $req->setMethod(HTTP_Request2::METHOD_POST);
     $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_edit');
     $req->addPostParameter('description', 'Test bookmark 2 for default privacy.');
     $req->addPostParameter('status', '0');
     $res = $req->send();
     $this->assertEquals(200, $res->getStatus(), 'Adding bookmark failed: ' . $res->getBody());
     $bms = $this->bs->getBookmarks(0, null, $uId);
     $bm = reset($bms['bookmarks']);
     $bmId = $bm['bId'];
     $reqUrl = $GLOBALS['unittestUrl'] . 'edit.php/' . $bmId . '?unittestMode=1';
     $req2 = new HTTP_Request2($reqUrl, HTTP_Request2::METHOD_POST);
     $req2->setCookieJar($cookies);
     $req2->addPostParameter('address', 'http://www.example.org/testdefaultprivacyposts_edit');
     $req2->addPostParameter('title', 'Test bookmark 2 for default privacy.');
     $req2->addPostParameter('submitted', '1');
     $res = $req2->send();
     $this->assertEquals(302, $res->getStatus(), 'Editing bookmark failed');
     $bm = $this->bs->getBookmark($bmId);
     $this->assertEquals('2', $bm['bStatus']);
 }
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:29,代码来源:editTest.php

示例2: post_request

    /**
     * POST Request
     *
     * @param $url
     * @param $datas
     * @return string
     */
    public function post_request($url, $datas = array())
    {
        $body = '';
        try {
            $this->http->setURL($url);
            $this->http->setMethod(HTTP_Request2::METHOD_POST);
            foreach ($datas as $key => $val) {
                $this->http->addPostParameter($key, mb_convert_encoding($val, $this->response_encoding, 'UTF-8'));
            }
            if (!empty($this->cookies)) {
                foreach ($this->cookies as $cookie) {
                    $this->http->addCookie($cookie['name'], $cookie['value']);
                }
            }

            $response = $this->http->send();
            if (count($response->getCookies())) {
                $this->cookies = $response->getCookies();
            }

            $body = mb_convert_encoding($response->getBody(), 'UTF-8', $this->response_encoding);

        } catch (Exception $e) {
            debug($e->getMessage());
        }

        return $body;
    }
开发者ID:nojimage,项目名称:twitter2mixivoice,代码行数:35,代码来源:Client.php

示例3: request

 /**
  * Http request
  *
  * @param string $method
  * @param string $url
  * @param array  $submit
  * @param string $formName
  *
  * @return HTTP_Request2_Response
  */
 public function request($method, $url, array $submit = array(), $formName = 'form')
 {
     $this->request = new HTTP_Request2();
     $url = new Net_URL2($url);
     $this->request->setMethod($method);
     if ($submit) {
         $submit = array_merge(array('_token' => '0dc59902014b6', '_qf__' . $formName => ''), $submit);
     }
     if ($submit && $method === 'POST') {
         $this->request->addPostParameter($submit);
     }
     if ($submit && $method === 'GET') {
         $url->setQueryVariables($submit);
     }
     $this->request->setUrl($url);
     $this->response = $this->request->send();
     return $this;
 }
开发者ID:ryo88c,项目名称:BEAR.Saturday,代码行数:28,代码来源:Client.php

示例4: send

 public function send($mobile, $content)
 {
     $data = array('u' => $this->conf['u'], 'p' => md5($this->conf['p']), 'm' => $mobile, 'c' => $content . $this->conf['sign']);
     $http = new HTTP_Request2($this->conf['apiUriPrefix'] . 'sms', HTTP_Request2::METHOD_POST);
     $http->addPostParameter($data);
     $r = $http->send()->getBody();
     if ($r != 0) {
         throw new Services_Sms_Exception($r);
     }
     return true;
 }
开发者ID:sdgdsffdsfff,项目名称:Services_Sms,代码行数:11,代码来源:Smsbao.php

示例5: send

 public function send($mobile, $content)
 {
     $data = array('sname' => $this->conf['sname'], 'spwd' => $this->conf['spwd'], 'scorpid' => $this->conf['scorpid'], 'sprdid' => $this->conf['sprdid'], 'sdst' => $mobile, 'smsg' => $content . $this->conf['sign']);
     $http = new HTTP_Request2($this->conf['apiUriPrefix'] . '/g_Submit', HTTP_Request2::METHOD_POST);
     $http->addPostParameter($data);
     $r = $http->send()->getBody();
     $tmp = $this->filter($r);
     if ($tmp['State'] != 0) {
         throw new Services_Sms_Exception($r);
     }
     return true;
 }
开发者ID:sdgdsffdsfff,项目名称:Services_Sms,代码行数:12,代码来源:Ihuyi.php

示例6: testStreaming

 public function testStreaming()
 {
     $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST);
     $body = $req->addPostParameter('foo', 'I am a parameter')->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt')->getBody();
     $asString = '';
     while ($part = $body->read(10)) {
         $asString .= $part;
     }
     $this->assertEquals($body->getLength(), strlen($asString));
     $this->assertContains('This is a test.', $asString);
     $this->assertContains('I am a parameter', $asString);
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:12,代码来源:MultipartBodyTest.php

示例7: request

 /**
  * リソースリクエスト実行
  *
  * リモートURLにアクセスしてRSSだったら配列に、
  * そうでなかったらHTTP Body文字列をリソースとして扱います。
  *
  * @return BEAR_Ro
  * @throws BEAR_Resource_Execute_Exception
  */
 public function request()
 {
     $reqMethod = array();
     $reqMethod[BEAR_Resource::METHOD_CREATE] = HTTP_Request2::METHOD_POST;
     $reqMethod[BEAR_Resource::METHOD_READ] = HTTP_Request2::METHOD_GET;
     $reqMethod[BEAR_Resource::METHOD_UPDATE] = HTTP_Request2::METHOD_PUT;
     $reqMethod[BEAR_Resource::METHOD_DELETE] = HTTP_Request2::METHOD_DELETE;
     assert(isset($reqMethod[$this->_config['method']]));
     try {
         // 引数以降省略可能  config で proxy とかも設定可能
         $request = new HTTP_Request2($this->_config['uri'], $reqMethod[$this->_config['method']]);
         $request->setHeader("user-agent", 'BEAR/' . BEAR::VERSION);
         $request->setConfig("follow_redirects", true);
         if ($this->_config['method'] === BEAR_Resource::METHOD_CREATE || $this->_config['method'] === BEAR_Resource::METHOD_UPDATE) {
             foreach ($this->_config['values'] as $key => $value) {
                 $request->addPostParameter($key, $value);
             }
         }
         $response = $request->send();
         $code = $response->getStatus();
         $headers = $response->getHeader();
         if ($code == 200) {
             $body = $response->getBody();
         } else {
             $info = array('code' => $code, 'headers' => $headers);
             throw $this->_exception($response->getBody(), $info);
         }
     } catch (HTTP_Request2_Exception $e) {
         throw $this->_exception($e->getMessage());
     } catch (Exception $e) {
         throw $this->_exception($e->getMessage());
     }
     $rss = new XML_RSS($body, 'utf-8', 'utf-8');
     PEAR::setErrorHandling(PEAR_ERROR_RETURN);
     // @todo Panda::setPearErrorHandling(仮称)に変更しエラーを画面化しないようにする
     $rss->parse();
     $items = $rss->getItems();
     if (is_array($items) && count($items) > 0) {
         $body = $items;
         $headers = $rss->getChannelInfo();
         $headers['type'] = 'rss';
     } else {
         $headers['type'] = 'string';
         $body = array($body);
     }
     // UTF-8に
     $encode = mb_convert_variables('UTF-8', 'auto', $body);
     $ro = BEAR::factory('BEAR_Ro')->setBody($body)->setHeaders($headers);
     /* @var $ro BEAR_Ro */
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('Panda', 'onPearError'));
     return $ro;
 }
开发者ID:ryo88c,项目名称:BEAR.Saturday,代码行数:61,代码来源:Http.php

示例8: post

 protected static function post($url, $content)
 {
     $request = new HTTP_Request2($url);
     $request->setMethod(HTTP_Request2::METHOD_POST);
     foreach ($content as $name => $val) {
         $request->addPostParameter($name, $val);
     }
     $request->setConfig(array('ssl_verify_peer' => false));
     try {
         $response = $request->send();
         $body = $response->getBody();
         return $body;
     } catch (HTTP_Request2_Exception $e) {
         return false;
     }
 }
开发者ID:wongatech,项目名称:instantor_php_api,代码行数:16,代码来源:InstantorRequest.php

示例9: post

 public function post($url, $data, $headers = array(), $auth = false)
 {
     $req = new HTTP_Request2($url);
     $req->setMethod(HTTP_Request2::METHOD_POST);
     $req->setHeader($headers);
     if ($auth) {
         $req->setAuth($auth['username'], $auth['password']);
     }
     //$req->setConfig('ssl_verify_peer', false);
     if (is_array($data)) {
         $req->addPostParameter($data);
     } else {
         $req->setBody($data);
     }
     $response = $req->send();
     return $response;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:17,代码来源:http.inc.php

示例10: send

 public function send($mobile, $content)
 {
     //需要国家码
     if (stripos($mobile, '86') !== 0) {
         $mobile = '86' . $mobile;
     }
     //移通 会在短信里自动加上签名【xxx】,所以不用自己加了。
     $data = array('command' => 'MT_REQUEST', 'spid' => $this->conf['spid'], 'sppassword' => $this->conf['sppassword'], 'da' => $mobile, 'dc' => '8', 'sm' => bin2hex(mb_convert_encoding($content, 'UTF-16BE', 'UTF-8')));
     $http = new HTTP_Request2($this->conf['apiUriPrefix'] . 'sms/mt', HTTP_Request2::METHOD_POST);
     $http->addPostParameter($data);
     $r = $http->send()->getBody();
     parse_str($r, $tmp);
     if ($tmp['mterrcode'] != '000') {
         throw new Services_Sms_Exception($r);
     }
     return true;
 }
开发者ID:sdgdsffdsfff,项目名称:Services_Sms,代码行数:17,代码来源:Etonenet.php

示例11: callback

 public static function callback()
 {
     global $HTTP_CONFIG;
     //exchange the code you get for a access_token
     $code = $_GET['code'];
     $request = new HTTP_Request2(self::ACCESS_TOKEN_URL);
     $request->setMethod(HTTP_Request2::METHOD_POST);
     $request->setConfig($HTTP_CONFIG);
     $request->addPostParameter(['client_id' => GITHUB_APP_ID, 'client_secret' => GITHUB_APP_SECRET, 'code' => $code]);
     $request->setHeader('Accept', 'application/json');
     $response = $request->send();
     $response = json_decode($response->getBody());
     $access_token = $response->access_token;
     //Use this access token to get user details
     $request = new HTTP_Request2(self::USER_URL . '?access_token=' . $access_token, HTTP_Request2::METHOD_GET, $HTTP_CONFIG);
     $response = $request->send()->getBody();
     $userid = json_decode($response)->login;
     //get the userid
     //If such a user already exists in the database
     //Just log him in and don't touch the access_token
     $already_present_token = Token::get('github', $userid);
     if ($already_present_token) {
         $_SESSION['userid'] = $userid;
         redirect_to('/');
     }
     if (defined('GITHUB_ORGANIZATION')) {
         // perform the organization check
         $request = new HTTP_Request2(json_decode($response)->organizations_url . '?access_token=' . $access_token, HTTP_Request2::METHOD_GET, $HTTP_CONFIG);
         $response = $request->send()->getBody();
         //List of organizations
         $organizations_list = array_map(function ($repo) {
             return $repo->login;
         }, json_decode($response));
         if (in_array(GITHUB_ORGANIZATION, $organizations_list)) {
             $_SESSION['userid'] = $userid;
             Token::add('github', $userid, $access_token);
         } else {
             throw new Exception('You are not in the listed members.');
         }
     } else {
         $_SESSION['userid'] = $userid;
         Token::add('github', $userid, $access_token);
     }
     redirect_to('/');
 }
开发者ID:nsystem1,项目名称:leaderboard,代码行数:45,代码来源:github.php

示例12: sendPOST

 /**
  * Send a POST request to the specified URL with the specified payload.
  * @param string $url
  * @param string $data
  * @return string Remote data
  **/
 public function sendPOST($url, $data = array())
 {
     $data['_fake_status'] = '200';
     // Send the actual request.
     $this->instance->setHeader('User-Agent', sprintf(Imgur::$user_agent, Imgur::$key));
     $this->instance->setMethod('POST');
     $this->instance->setUrl($url);
     foreach ($data as $k => $v) {
         $this->instance->addPostParameter($k, $v);
     }
     try {
         /** @var HTTP_Request2_Response */
         $response = $this->instance->send();
         return $response->getBody();
     } catch (HTTP_Request2_Exception $e) {
         throw new Imgur_Exception("HTTP Request Failure", null, $e);
     } catch (Exception $e) {
         throw new Imgur_Exception("Unknown Failure during HTTP Request", null, $e);
     }
 }
开发者ID:plehnet,项目名称:Imgur-API-for-PHP,代码行数:26,代码来源:PEARHTTPRequest2.php

示例13: requestToPostMethod

 public static function requestToPostMethod($argURL, $argParams = NULL, $argFiles = NULL, $argTimeOut = 60)
 {
     $HttpRequestObj = new HTTP_Request2();
     $urls = parse_url($argURL);
     if (isset($urls["user"]) && isset($urls["pass"])) {
         $HttpRequestObj->setAuth($urls["user"], $urls["pass"]);
     }
     if (isset($urls["port"])) {
         $url = $urls["scheme"] . '://' . $urls["host"] . ':' . $urls["port"];
     } else {
         $url = $urls["scheme"] . '://' . $urls["host"];
     }
     if (isset($urls["path"])) {
         $url .= $urls["path"];
     }
     $HttpRequestObj->setUrl($url);
     $HttpRequestObj->setMethod(HTTP_Request2::METHOD_POST);
     if ('https' === $urls["scheme"]) {
         $HttpRequestObj->setConfig(array('connect_timeout' => $argTimeOut, 'timeout' => $argTimeOut, 'adapter' => 'HTTP_Request2_Adapter_Curl', 'ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE));
     } else {
         $HttpRequestObj->setConfig(array('connect_timeout' => $argTimeOut, 'timeout' => $argTimeOut));
     }
     if (is_array($argParams)) {
         foreach ($argParams as $key => $value) {
             $HttpRequestObj->addPostParameter($key, $value);
         }
     }
     // ファイルをアップロードする場合
     if (is_array($argFiles)) {
         foreach ($argFiles as $key => $value) {
             $HttpRequestObj->addUpload($key, $value);
         }
     }
     // リクエストを送信
     $response = $HttpRequestObj->send();
     // レスポンスのボディ部を表示
     return $response;
 }
开发者ID:s-nakazawa,项目名称:UNICORN,代码行数:38,代码来源:GenericHttpRequest.class.php

示例14: delete_mailinglist

 public function delete_mailinglist($list)
 {
     $req = new HTTP_Request2($this->url . "/com/delmailinglistnow");
     $req->setMethod(HTTP_Request2::METHOD_POST);
     $req->getUrl()->setQueryVariables($this->auth);
     $req->addPostParameter(array('modu' => $list));
     $resp = $req->send();
     // refresh lists in class
     $this->get_mailinglists();
 }
开发者ID:tothi,项目名称:php-mailinglist,代码行数:10,代码来源:MailingList.php

示例15: query

 /**
  * Performs a simple Query.
  *
  * Performs a query and returns the result in the selected format. Throws an
  * exception if the query returns an error. 
  *
  * @param	string	$query			String used for query
  * @param	string	$resultFormat	Returned result format, see const definitions for supported list.
  * @param	string	$queryLang		Language used for querying, SPARQL and SeRQL supported
  * @param	bool	$infer			Use inference in the query
  *
  * @return	phpSesame_SparqlRes
  */
 public function query($query, $resultFormat = self::SPARQL_XML, $queryLang = 'sparql', $infer = true)
 {
     $this->checkRepository();
     $this->checkQueryLang($queryLang);
     $this->checkResultFormat($resultFormat);
     $request = new HTTP_Request2($this->dsn . '/repositories/' . $this->repository, HTTP_Request2::METHOD_POST);
     $request->setHeader('Accept: ' . self::SPARQL_XML);
     $request->addPostParameter('query', $query);
     $request->addPostParameter('queryLn', $queryLang);
     $request->addPostParameter('infer', $infer);
     $response = $request->send();
     if ($response->getStatus() != 200) {
         print_r('query: ' . $query);
         var_dump($response);
         throw new Exception('Failed to run query, HTTP response error: ' . $response->getStatus());
     }
     //print_r('No error: '.$response->getStatus());
     //print_r('request: '.$request->getHeaders());
     //print_r($response->getBody());
     return new phpSesame_SparqlRes($response->getBody());
 }
开发者ID:p4535992,项目名称:programate,代码行数:34,代码来源:phpSesame.php


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