當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Http::getContent方法代碼示例

本文整理匯總了PHP中Http::getContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::getContent方法的具體用法?PHP Http::getContent怎麽用?PHP Http::getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Http的用法示例。


在下文中一共展示了Http::getContent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: daemonFunc

 /**
  * 完善daemon處理函數,此函數必備
  *
  *
  */
 function daemonFunc()
 {
     require dirname(__FILE__) . '/../../config/testUI/config.php';
     $redis = new Predis\Client($_config['redis_server']);
     $http = new Http();
     while ($this->subProcessCheck()) {
         //處理隊列
         $case_data = $redis->lpop($_config['queue_name']);
         if (empty($case_data)) {
             break;
         } else {
             $arr = json_decode($case_data, true);
             $url = $arr['host'] . $arr['url'];
             $query = $arr['param'];
             $method = strtoupper($arr['method']);
             //拚裝表單提交數據
             $formdata = array();
             $temp_arry = explode('&', $query);
             foreach ($temp_arry as $item) {
                 list($k, $v) = explode('=', $item);
                 $formdata[$k] = $v;
             }
             //判斷是否需要token
             if (isset($arr['token'])) {
                 $formdata['token'] = $arr['token'];
             }
             if ($method == 'GET') {
                 $http->get($url, $formdata);
             } else {
                 $http->post($url, $formdata);
             }
             $res = $http->getContent();
             //此處增加返回結果的判斷
             $result = $arr['result'];
             if ($result == $res) {
                 $res_test = 1;
             } else {
                 $res_test = 0;
             }
             //                $req['url'] = $url;
             //                $req['data'] = $formdata;
             //$result =array();
             file_put_contents(realpath(dirname(__FILE__)) . '/../../output/testUI.log', $res_test . '|' . $result . '|' . $res . '|' . $url . '|' . json_encode($formdata) . "\n", FILE_APPEND);
         }
         //增加處理數,不增加處理數,就需要子進程本身有退出機製。
         //$this->requestCount++;
         //釋放時間片
         usleep(5000);
     }
 }
開發者ID:mendianchun,項目名稱:at,代碼行數:55,代碼來源:index.php

示例2: act_accountInforIntegation

 public function act_accountInforIntegation()
 {
     $dpId = $_REQUEST['dpId'];
     $developerMod = M('Developer');
     if (!$dpId) {
         self::$errMsg['12000'] = "未獲取到該用戶的ID,無法同步信息至開放係統!";
         return false;
     }
     $basInfoSta = $developerMod->getDeveloper("*", "id = " . $dpId);
     if (!empty($basInfoSta)) {
         $sendInfor = array("username" => $basInfoSta[0]['app_key'], "password" => $basInfoSta[0]['login_pwd'], "token" => $basInfoSta[0]['token'], "groupid" => 10, "email" => $basInfoSta[0]['email'], "mobile" => $basInfoSta[0]['phone'], "qq" => '', "address" => $basInfoSta[0]['address2'] . " " . $basInfoSta[0]['address'], "company" => $basInfoSta[0]['company'], "status" => $basInfoSta[0]['status'], "regtime" => $basInfoSta[0]['create_time'], "regip" => '', "logintime" => '', "loginip" => '');
     } else {
         self::$errMsg[10131] = get_promptmsg(10131, '分銷商');
         return false;
     }
     $synStatus = array();
     //開始同步到開放係統 外網
     include_once WEB_PATH . 'lib/service/http.php';
     $http = new Http('http://idc.open.valsun.cn/admin_open/openInterface.php');
     $http->addPostParam(array('distributionBasicInfor' => json_encode($sendInfor)));
     $http->addHeader("Author:zoujunrong");
     if (!$http->post()) {
         //如果是javascript請求,輸出是給javascript的,可能就需要對輸出轉碼
         self::$errMsg[10145] = get_promptmsg(10145, $http->err_str);
         return false;
     } else {
         // 			echo $http->getResponse('header')."---header<br/>";
         $synStatus["outOpenSystem"] = $http->getContent();
     }
     //開始同步到開放係統 外網
     $http->setURL('http://open.valsun.cn:88/admin_open/openInterface.php');
     $http->addPostParam(array('distributionBasicInfor' => json_encode($sendInfor)));
     $http->addHeader("Author:zoujunrong");
     if (!$http->post()) {
         //如果是javascript請求,輸出是給javascript的,可能就需要對輸出轉碼
         self::$errMsg[10146] = get_promptmsg(10146, $http->err_str);
         return false;
     } else {
         // 			echo $http->getResponse('header')."---header<br/>";
         $synStatus["innerOpenSystem"] = $http->getContent();
     }
     return $synStatus;
 }
開發者ID:bizonix,項目名稱:sailvan,代碼行數:43,代碼來源:apiIntegration.action.php

示例3: quickGet

 static function quickGet($url)
 {
     $bits = parse_url($url);
     $host = $bits['host'];
     $port = isset($bits['port']) ? $bits['port'] : 80;
     $path = isset($bits['path']) ? $bits['path'] : '/';
     if (isset($bits['query'])) {
         $path .= '?' . $bits['query'];
     }
     $client = new Http($host, $port);
     if (!$client->get($path)) {
         return false;
     } else {
         return $client->getContent();
     }
 }
開發者ID:zzzzzmh,項目名稱:KeywordFilteringService,代碼行數:16,代碼來源:Http.php


注:本文中的Http::getContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。