當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。