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


PHP HTTPRequest类代码示例

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


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

示例1: DownloadToString

 function DownloadToString()
 {
     $crlf = "\r\n";
     // generate request
     $req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . $crlf;
     // fetch
     $this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
     fwrite($this->_fp, $req);
     while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) {
         $response .= fread($this->_fp, 1024);
     }
     fclose($this->_fp);
     // split header and body
     $pos = strpos($response, $crlf . $crlf);
     if ($pos === false) {
         return $response;
     }
     $header = substr($response, 0, $pos);
     $body = substr($response, $pos + 2 * strlen($crlf));
     // parse headers
     $headers = array();
     $lines = explode($crlf, $header);
     foreach ($lines as $line) {
         if (($pos = strpos($line, ':')) !== false) {
             $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
         }
     }
     // redirection?
     if (isset($headers['location'])) {
         $http = new HTTPRequest($headers['location']);
         return $http->DownloadToString($http);
     } else {
         return $body;
     }
 }
开发者ID:Bakyenga,项目名称:kyengs,代码行数:35,代码来源:class.httprequest.php

示例2: userIsAdmin

 /**
  * @param HTTPRequest $request
  * @return bool
  */
 public function userIsAdmin(HTTPRequest $request)
 {
     $user = $request->getCurrentUser();
     $forge_user_manager = new User_ForgeUserGroupPermissionsManager(new User_ForgeUserGroupPermissionsDao());
     $has_special_permission = $forge_user_manager->doesUserHavePermission($user, new User_ForgeUserGroupPermission_MediawikiAdminAllProjects());
     return $has_special_permission || $user->isMember($request->getProject()->getID(), 'A');
 }
开发者ID:rinodung,项目名称:tuleap,代码行数:11,代码来源:ServiceMediawiki.class.php

示例3: retrieve_user_details

 public function retrieve_user_details()
 {
     // Get the stream to the user page via the Snipt API
     $request = new HTTPRequest(SNIPT_API . SNIPT_USER . SNIPT_FORMAT, HTTP_METH_GET);
     echo "Connecting to Snipt API....\n";
     $request->send();
     if ($request->getResponseCode() == 200) {
         $this->user_details = json_decode($request->getResponseBody());
         echo "Snipt entries to retrieve : {$this->user_details->count}\n";
         foreach ($this->user_details->snipts as $snipt) {
             // Retrieve the snipt entry
             $request = new HTTPRequest(SNIPT_API . SNIPT_SNIPT . $snipt . "." . SNIPT_FORMAT . SNIPT_STYLE);
             $request->send();
             if ($request->getResponseCode() == 200) {
                 $this->snipts[$snipt] = json_decode($request->getResponseBody());
             } else {
                 echo "[ERROR] Could not retrieve the data for snipt entry {$snipt}\n";
             }
         }
         return true;
     } else {
         echo "Invalid data received, exiting....\n";
         return false;
     }
 }
开发者ID:jc1arke,项目名称:codesnippit-sniptnet-importer,代码行数:25,代码来源:snipt.importer.php

示例4: processReminder

 /**
  * Process date reminder requests
  *
  * @param TrackerManager $trackerManager
  * @param HTTPRequest    $request
  * @param PFUser           $currentUser
  *
  * @return Void
  */
 public function processReminder(TrackerManager $trackerManager, HTTPRequest $request, $currentUser)
 {
     $action = $request->get('action');
     $do_redirect = false;
     $feedback = false;
     try {
         if ($request->get('submit') && $action == 'new_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->addNewReminder($request);
             $feedback = 'tracker_date_reminder_added';
             $do_redirect = true;
         } elseif ($request->get('submit') && $action == 'update_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->editTrackerReminder($request);
             $feedback = 'tracker_date_reminder_updated';
             $do_redirect = true;
         } elseif ($request->get('confirm_delete') && $action == 'confirm_delete_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->deleteTrackerReminder($request->get('reminder_id'));
             $feedback = 'tracker_date_reminder_deleted';
         }
         if ($feedback) {
             $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_date_reminder', $feedback));
         }
     } catch (Tracker_DateReminderException $e) {
         $GLOBALS['Response']->addFeedback('error', $e->getMessage());
     }
     if ($do_redirect || $request->get('cancel_delete_reminder')) {
         $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?func=admin-notifications&tracker=' . $this->getTracker()->getId());
     }
 }
开发者ID:ansarbek,项目名称:tuleap,代码行数:37,代码来源:Tracker_DateReminderManager.class.php

示例5: __construct

 public function __construct($path = NULL)
 {
     $this->FS = new FS();
     $this->httpResponse = new HTTPResponse();
     $this->httpRequest = new HTTPRequest();
     $this->path = isset($path) ? $path : ($this->httpRequest->getExists('path') ? $this->httpRequest->getData('path') : NULL);
 }
开发者ID:na2axl,项目名称:FlatOS,代码行数:7,代码来源:RawData.php

示例6: submit

    protected static function submit()
    {
        $id = $_GET['item'];
        $item = Items::get_instance()->get_item($id);
        if (false === $item) {
            throw new Exception(_r('Invalid item ID specified', 'instapaper'));
        }
        $user = get_option('instapaper_user');
        if (empty($user)) {
            throw new Exception(sprintf(_r('Please set your username and password in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
        }
        if (!check_nonce('instapaper-submit', $_GET['_nonce'])) {
            throw new Exception(_r('Nonces did not match. Try again.', 'instapaper'));
        }
        $data = array('username' => get_option('instapaper_user', ''), 'password' => get_option('instapaper_pass', ''), 'url' => $item->permalink, 'title' => apply_filters('the_title', $item->title));
        $request = new HTTPRequest('', 2);
        $response = $request->post("https://www.instapaper.com/api/add", array(), $data);
        switch ($response->status_code) {
            case 400:
                throw new Exception(_r('Internal error. Please report this.', 'instapaper'));
            case 403:
                throw new Exception(sprintf(_r('Invalid username/password. Please check your details in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
            case 500:
                throw new Exception(_r('An error occurred when contacting Instapaper. Please try again later.', 'instapaper'));
        }
        Instapaper::page_head();
        ?>
		<div id="message">
			<h1><?php 
        _e('Success!');
        ?>
</h1>
			<p class="sidenote"><?php 
        _e('Closing window in...', 'instapaper');
        ?>
</p>
			<p class="sidenote" id="counter">3</p>
		</div>
		<script>
			$(document).ready(function () {
				setInterval(countdown, 1000);
			});

			function countdown() {
				if(timer > 0) {
					$('#counter').text(timer);
					timer--;
				}
				else {
					self.close();
				}
			}

			var timer = 2;
		</script>
	<?php 
        Instapaper::page_foot();
        die;
    }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:59,代码来源:instapaper.php

示例7: getPostData

 function getPostData()
 {
     $var = new HTTPRequest();
     $username = $var->get('username');
     $password = $var->get('password');
     //$option=$var->get('option');
     $this->check($username, $password);
 }
开发者ID:nuthankumarns,项目名称:vts-source---services,代码行数:8,代码来源:login_api.php

示例8: executeAnnounceList

 public function executeAnnounceList(HTTPRequest $request)
 {
     $announceId = htmlspecialchars($request->getData('announceId'));
     $listOfFeedbacks = $this->_feedbacksManager->getByAnnounceId($announceId);
     $this->page->smarty()->assign('listOfFeedbacks', $listOfFeedbacks);
     $this->page->smarty()->assign('profilesManager', $this->_profilesManager);
     $this->page->smarty()->assign('usersManager', $this->_usersManager);
 }
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:8,代码来源:FeedbackController.class.php

示例9: call

	/**
	 * Faz a requisição no webservice
	 * @return	string XML de retorno
	 */
	public function call() {
		$this->httpRequester->open( $this->url );

		$this->requestXML = $this->createXMLNode();
		$this->responseXML = $this->httpRequester->execute( array( 'mensagem' => $this->requestXML ) , HTTPRequestMethod::POST );

		return $this->responseXML;
	}
开发者ID:netojoaobatista,项目名称:cielo,代码行数:12,代码来源:AbstractCieloNode.php

示例10: getPostData

 function getPostData()
 {
     $var = new HTTPRequest();
     $user_id = $var->get('user_id');
     //var_dump($user_id);
     //$password=$var->get('password');
     //$option=$var->get('option');
     $this->vehicleDetails($user_id);
 }
开发者ID:nuthankumarns,项目名称:vts-source---services,代码行数:9,代码来源:get_vehicle.php

示例11: response

 protected function response($data)
 {
     $request = new HTTPRequest($this->gateway->getHost(), $this->endpoint, 'POST', true);
     $result = $request->connect($data);
     if ($result < 400) {
         return $request;
     }
     return false;
 }
开发者ID:aircross,项目名称:paypal-recurring-payments,代码行数:9,代码来源:PaypalBase.php

示例12: process

 public function process(HTTPRequest $request)
 {
     if (!PluginManager::instance()->isPluginAllowedForProject($this, $request->getProject()->getId())) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_svn_manage_repository', 'plugin_not_activated'));
         $GLOBALS['Response']->redirect('/projects/' . $request->getProject()->getUnixNameMixedCase() . '/');
     } else {
         $this->getRouter()->route($request);
     }
 }
开发者ID:blestab,项目名称:tuleap,代码行数:9,代码来源:svnPlugin.class.php

示例13: executeDelete

 public function executeDelete(HTTPRequest $request)
 {
     $id = $request->getData('carrouselId');
     $carrousel = $this->_carrouselsManager->get($id);
     $announceId = $carrousel->getAnnounceId();
     $this->_carrouselsManager->delete($id);
     $this->app->httpResponse()->redirect('/view/member/announce-' . $announceId);
     exit;
 }
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:9,代码来源:CarrouselController.class.php

示例14: response

 /**
  * @return HTTPRequest
  */
 private function response($data)
 {
     $r = new HTTPRequest($this->host, $this->endpoint, 'POST', true);
     $result = $r->connect($data);
     if ($result < 400) {
         return $r;
     }
     return false;
 }
开发者ID:craighays,项目名称:nsfhp,代码行数:12,代码来源:paypal.php

示例15: settheme

 public function settheme(HTTPRequest $request)
 {
     $newTheme = $request->param("ID");
     $newTheme = Convert::raw2sql($newTheme);
     DB::query("Update SiteConfig SET Theme = '{$newTheme}';");
     Session::set("theme", $newTheme);
     SSViewer::flush_template_cache();
     $this->redirect($this->Link());
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-test,代码行数:9,代码来源:Page.php


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