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


PHP Http类代码示例

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


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

示例1: updateMail

 public function updateMail()
 {
     $id = $this->rcpt;
     $http = new Http();
     $url = "http://services.ukrposhta.com/barcodesingle/default.aspx?ctl00%24centerContent%24scriptManager=ctl00%24centerContent%24scriptManager%7Cctl00%24centerContent%24btnFindBarcodeInfo&__EVENTTARGET=&__EVENTARGUMENT=&ctl00%24centerContent%24txtBarcode={$id}&__ASYNCPOST=true&ctl00%24centerContent%24btnFindBarcodeInfo=%D0%9F%D0%BE%D1%88%D1%83%D0%BA";
     $data = $http->http_request(array('url' => $url, 'cookie' => true, 'redirect' => true));
     $page = split("\n", $data);
     $print = 0;
     foreach ($page as $line) {
         if ($print) {
             $result = strip_tags($line) . "\n";
             $print = 0;
         }
         if (strstr("{$line}", "divInfo")) {
             if (strstr("{$line}", "</div>")) {
                 $result = strip_tags($line) . "\n";
             } else {
                 $print = 1;
             }
         }
     }
     if (strstr($result, "вручене за довіреністю")) {
         $this->ddate = date("Y-m-d", strtotime(mb_substr(strstr($result, "вручене за довіреністю "), 23, 10, 'UTF-8')));
         $this->status = 1;
         $this->update();
     } elseif (strstr($result, "вручене адресату (одержувачу) особисто")) {
         $this->ddate = date("Y-m-d", strtotime(mb_substr(strstr($result, "особисто "), 9, 10, 'UTF-8')));
         $this->status = 1;
         $this->update();
     } else {
         return 0;
     }
 }
开发者ID:snipesn,项目名称:UkrYama-2,代码行数:33,代码来源:HoleRequestSent.php

示例2: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     try {
         $Customer = new CustomerModel();
         $verifEmail = $Customer->sameMail($formFields['Email']);
         if ($verifEmail && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && $formFields['password2'] == $formFields['password'] && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
             $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
             //var_dump($Birthdate);
             $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
             //var_dump($Customer_id);
             $user = $Customer->findCustomer($Customer_id);
             $UserSession = new UserSession();
             $UserSession->create($user);
             $http->redirectTo('');
         } else {
             $http->redirectTo('Exception?Error=3');
         }
     } catch (DomainException $event) {
         $form = new RegisterForm();
         $form->bind($formFields);
         $form->setErrorMessage($event->getMessage());
         return ['_form' => $form];
     }
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:30,代码来源:UserController.class.php

示例3: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     /*var_dump($formFields['bookingDate']);
     		var_dump($date);
     		var_dump($date > $formFields['bookingDate']);
     		
     		die();*/
     $date = new DateTime();
     $userSession = new UserSession();
     $bookingModel = new BookingModel();
     $customerId = intval($userSession->getId());
     if ($userSession->isAuthenticated()) {
         $customerId = intval($userSession->getId());
         $checkBookingById = $bookingModel->checkBookingById($customerId, intval($formFields['bookingId']), $formFields['bookingDate']);
         if (ctype_digit($formFields['bookingId']) && $date < new DateTime($formFields['bookingDate']) && $checkBookingById) {
             $bookingModel->DeletBooking($formFields['bookingId']);
             $flashBag = new FlashBag();
             $flashBag->add('Réservation ' . $formFields["bookingId"] . ' bien supprimée');
             $http->redirectTo('/');
         }
         $flashBag = new FlashBag();
         $flashBag->add('Problème lors de la suppression de la réservation (Vous ne pouvez supprimer des réservations posterieur à aujourd\'hui)');
         $http->redirectTo('/Booking');
     }
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:31,代码来源:SupbookingController.class.php

示例4: httpGetMethod

 public function httpGetMethod(Http $http, array $queryFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP GET
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $queryFields contient l'équivalent de $_GET en PHP natif.
      */
     //var_dump(intval($queryFields['produit_id']));
     if (array_key_exists('produit_id', $queryFields)) {
         if (ctype_digit($queryFields['produit_id'])) {
             $meal = new MealModel();
             $listMeal = $meal->find(intval($queryFields['produit_id']));
             if ($listMeal) {
                 return ['listMeal' => $listMeal];
             } else {
                 $http->redirectTo('Exception?Error=1');
             }
         } else {
             $http->redirectTo('Exception?Error=2');
         }
     } else {
         $http->redirectTo('Exception?Error=2');
         //'On ne hack pas mon site !!!!!!!!!!!!!!!!', 'Image' => 'http://iletaitungeek.com/wp-content/uploads/2015/08/dark-vador-aura-sa-ps4-collector-une.jpg'];
     }
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:26,代码来源:MealController.class.php

示例5: refresh

 function refresh($force = false)
 {
     // How often to check for updates
     $interval = $this->hook->apply('product_info_refresh_interval', 60 * 60 * 12);
     if (!$force && isset($this->data['last_refresh']) && $this->data['last_refresh'] > time() - $interval) {
         return false;
     }
     $http = new Http($this->config, $this->hook, $this->router);
     $response = $http->get($this->config->leeflets_api_url . '/product-info?slugs=core');
     if (Error::is_a($response)) {
         return $response;
     }
     if ((int) $response['response']['code'] < 200 || (int) $response['response']['code'] > 399) {
         return new Error('product_info_refresh_fail_http_status', 'Failed to refresh product info from leeflets.com. Received response ' . $response['response']['code'] . ' ' . $response['response']['message'] . '.', $response);
     }
     if (!($response_data = json_decode($response['body'], true))) {
         return new Error('product_info_refresh_fail_json_decode', 'Failed to refresh product info from leeflets.com. Error decoding the JSON response received from the server.', $response['body']);
     }
     $this->data = array();
     $this->data['last_refresh'] = time();
     $this->data['products'] = $response_data;
     $this->write();
     $this->load();
     return true;
 }
开发者ID:pcbrsites,项目名称:leeflets,代码行数:25,代码来源:product-info.php

示例6: testGetParameters

 public function testGetParameters()
 {
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_GET['captain'] = 'kirk';
     $request = new Http();
     $this->assertEquals('kirk', $request->getParameter('captain'));
 }
开发者ID:poliander,项目名称:janeiro,代码行数:7,代码来源:HttpTest.php

示例7: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     $userSession = new UserSession();
     if ($userSession->isAdminAuthenticated() == false) {
         $http->redirectTo('/');
     }
     //var_dump($formFields);
     //var_dump($_FILES);
     if (array_key_exists('Modification', $formFields)) {
         if ($http->hasUploadedFile('Photo')) {
             $pathinfo = $http->moveUploadedFile('Photo', '/images/meals');
             var_dump($pathinfo);
             $mealModel = new MealModel();
             $mealModel->modifyPicture($pathinfo, $formFields['Id']);
         }
         $mealModel = new MealModel();
         $result = $mealModel->modifyMeal($formFields['Name'], $formFields['Description'], $formFields['QuantityInStock'], $formFields['BuyPrice'], $formFields['SalePrice'], $formFields['Id']);
         $http->redirectTo('/Admin/List');
     } elseif (ctype_digit($formFields['meal_Id'])) {
         $mealModel = new MealModel();
         $meal = $mealModel->find($formFields['meal_Id']);
         return ['meal' => $meal];
     }
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:30,代码来源:ModificationController.class.php

示例8: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     /*$date = new DateModel();
     		var_dump($date->testDate($formFields['dateResa'])); //0 FAUX - 1 VRAI REJEX */
     $userSession = new UserSession();
     if ($userSession->isAuthenticated()) {
         $dateTime = date_create($formFields['dateResa'] . ' ' . $formFields['timeResa']);
         $now = new DateTime("now");
         $resaDate = date_format($dateTime, 'Y-m-d');
         $resaTime = date_format($dateTime, 'H:i:s');
         //var_dump($formFields);
         if (!empty($formFields['dateResa']) && !empty($formFields['timeResa']) && !empty($formFields['NumberOfSeats']) && $dateTime > $now && ctype_digit($formFields['NumberOfSeats'])) {
             $userId = $userSession->getId();
             $Booking = new BookingModel();
             $resultat = $Booking->register($userId, $resaDate, $resaTime, $formFields['NumberOfSeats']);
             return ['resultat' => $resultat];
         } elseif ($dateTime < $now) {
             return ['Error' => 'Nous ne pouvons vous réserver une table pour une date antérieur à aujourd\'hui'];
         } else {
             return ['Error' => 'Un champ n\'a pas était remplie correctement'];
         }
     } else {
         echo 'lu';
         die;
         $http->redirectTo('/');
     }
 }
开发者ID:annacrea,项目名称:ChezPaolo,代码行数:33,代码来源:BookingController.class.php

示例9: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     $Customer = new CustomerModel();
     $verifEmail = $Customer->sameMail($formFields['Email']);
     //var_dump(strlen($_POST['Phone']));
     //var_dump(strlen($_POST['ZipCode']));
     if ($verifEmail['result'] === '0' && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
         $password = password_hash($formFields['password'], PASSWORD_DEFAULT);
         //var_dump($password);
         $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
         //var_dump($Birthdate);
         $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
         //var_dump($Customer_id);
         $user = $Customer->findCustomer($Customer_id);
         $UserSession = new UserSession();
         $UserSession->create($user);
         $http->redirectTo('');
     } elseif ($verifEmail != '0') {
         $http->redirectTo('Exception?Error=3');
     }
 }
开发者ID:annacrea,项目名称:ChezPaolo,代码行数:27,代码来源:UserController.class.php

示例10: isNewBrowscapVersion

function isNewBrowscapVersion()
{
    if (!isset($_SESSION['user_browscap_version'])) {
        $_SESSION['user_browscap_version'] = getCurrentBrowscapRelease();
    }
    if (!isset($_SESSION['server_browscap_version'])) {
        $server_browscap_version = "";
        if (extension_loaded('soap')) {
            $http = new Http();
            $http->setTimeout(2);
            $http->execute("http://www.website-php.com/en/webservices/wsp-information-server.wsdl?wsdl");
            $wsdl = $http->getResult();
            if ($wsdl != "" && find($wsdl, "<?xml", 1) > 0) {
                $client = new WebSitePhpSoapClient("http://www.website-php.com/en/webservices/wsp-information-server.wsdl?wsdl");
                $server_browscap_version = $client->getBrowscapVersionNumber();
            }
        } else {
            /*$http = new Http();
            		$http->setTimeout(2);
            		$http->execute("http://browsers.garykeith.com/versions/version-number.asp");
            		$server_browscap_version = $http->getResult();*/
            $server_browscap_version = "";
        }
        if (trim($server_browscap_version) != "") {
            $_SESSION['server_browscap_version'] = $server_browscap_version;
        }
    }
    if (trim($_SESSION['user_browscap_version']) != trim($_SESSION['server_browscap_version'])) {
        return trim($_SESSION['server_browscap_version']);
    }
    return false;
}
开发者ID:kxopa,项目名称:WebSite-PHP,代码行数:32,代码来源:utils-version.inc.php

示例11: httpGetMethod

 public function httpGetMethod(Http $http, array $queryFields)
 {
     if (isset($_GET['logout']) && $_GET['logout'] == 'out') {
         $userSession = new UserSession();
         $userSession->destroy();
         $http->redirectTo('/');
     }
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:8,代码来源:LogoutController.class.php

示例12: actionGetAddress

 public function actionGetAddress()
 {
     header('Access-Control-Allow-Origin: *');
     $lat = $_POST['lat'];
     $lng = $_POST['lng'];
     $uri = "http://maps.googleapis.com/maps/api/geocode/json?latlng={$lat},{$lng}&language=uk&sensor=false";
     $r = new Http();
     echo $r->http_request($uri);
 }
开发者ID:snipesn,项目名称:UkrYama-2,代码行数:9,代码来源:EventController.php

示例13: getTicket

 /**
  * 获取jsticket
  *
  * @return string
  */
 public function getTicket()
 {
     $key = 'overtrue.wechat.jsapi_ticket' . $this->appId;
     return $this->cache->get($key, function ($key) {
         $http = new Http(new AccessToken($this->appId, $this->appSecret));
         $result = $http->get(self::API_TICKET);
         $this->cache->set($key, $result['ticket'], $result['expires_in']);
         return $result['ticket'];
     });
 }
开发者ID:emilymwang8,项目名称:ajk-broker,代码行数:15,代码来源:Js.php

示例14: post_func

 function post_func($url, $params, $files)
 {
     $http = new Http($this->key);
     if ($http->upload($url, $params, $files)) {
         //var_export($http->get_data());
         return json_decode($http->get_data(), true);
     } else {
         return array('result' => false, 'error' => 7.1);
     }
 }
开发者ID:zeus911,项目名称:versionSwitchTool,代码行数:10,代码来源:VersionSwitch.php

示例15: httpGetMethod

 public function httpGetMethod(Http $http, array $queryFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP GET
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $queryFields contient l'équivalent de $_GET en PHP natif.
      */
     $http->refreshTo(10, '');
     return ['Error' => $queryFields['Error']];
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:11,代码来源:ExceptionController.class.php


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