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


PHP Curl::setBasicAuthentication方法代碼示例

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


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

示例1: process_user

 public function process_user($username, $password, $facility_code)
 {
     $curl = new Curl();
     $response = array();
     //Get Supplier
     $supplier = $this->get_supplier($facility_code);
     if ($supplier == "kemsa") {
         //Use nascop url
         $url = $this->default_url;
         $post = array("email" => $username, "password" => $password);
         $url = $this->default_url . 'sync/user';
         $curl->post($url, $post);
     } else {
         //Use escm url
         $curl->setBasicAuthentication($username, $password);
         $curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE);
         $url = $this->default_url . 'user/' . $username;
         $curl->get($url);
     }
     //Handle Response
     if ($curl->error) {
         $response['error'] = TRUE;
         $response['content'] = array($curl->error_code);
     } else {
         $response['error'] = FALSE;
         $response['content'] = json_decode($curl->response, TRUE);
     }
     return json_encode($response);
 }
開發者ID:OmondiKevin,項目名稱:ADT_MTRH,代碼行數:29,代碼來源:cdrr_logic.php

示例2: testBasicHttpAuth

 public function testBasicHttpAuth()
 {
     $data = array();
     $this->curl->get(self::TEST_URL . '/http_basic_auth.php', $data);
     $this->assertEquals('canceled', $this->curl->response);
     $username = 'myusername';
     $password = 'mypassword';
     $this->curl->setBasicAuthentication($username, $password);
     $this->curl->get(self::TEST_URL . '/http_basic_auth.php', $data);
     $this->assertEquals('{"username":"myusername","password":"mypassword"}', $this->curl->response);
 }
開發者ID:php-mod,項目名稱:curl,代碼行數:11,代碼來源:CurlTest.php

示例3: get_updates

 public function get_updates($type = 0)
 {
     if ($type != 0) {
         if ($this->session->userdata("update_timer") != "") {
             $to_time = strtotime(date('Y-m-d H:i:s'));
             $from_time = strtotime($this->session->userdata("update_timer"));
             if (round(abs($to_time - $from_time) / 60, 2) <= 10) {
                 $this->session->set_userdata("update_test", false);
                 echo 2;
                 die;
             }
         }
         $this->session->set_userdata("update_timer", date('Y-m-d H:i:s'));
     }
     ini_set("max_execution_time", "1000000");
     $current_month_start = date('Y-m-01');
     $one_current_month_start = date('Y-m-d', strtotime($current_month_start . "-1 month"));
     $two_current_month_start = date('Y-m-d', strtotime($current_month_start . "-2 months"));
     $three_current_month_start = date('Y-m-d', strtotime($current_month_start . "-3 months"));
     $facility_code = $this->session->userdata('facility');
     $api_userID = $this->session->userdata('api_id');
     $facility_list = User_Facilities::getHydratedFacilityList($api_userID);
     $lists = json_decode($facility_list['facility'], TRUE);
     $facility = Facilities::getSupplier($facility_code);
     $supplier = $facility->supplier->name;
     $links = array();
     $curl = new Curl();
     if (strtoupper($supplier) == "KENYA PHARMA") {
         $url = $this->esm_url;
         foreach ($lists as $facility_id) {
             if ($type == 0) {
                 $links[] = "facility/" . $facility_id . "/cdrr";
                 $links[] = "facility/" . $facility_id . "/maps";
             } else {
                 $links[] = "facility/" . $facility_id . "/cdrr/" . $current_month_start;
                 $links[] = "facility/" . $facility_id . "/maps/" . $current_month_start;
                 $links[] = "facility/" . $facility_id . "/cdrr/" . $one_current_month_start;
                 $links[] = "facility/" . $facility_id . "/maps/" . $one_current_month_start;
                 $links[] = "facility/" . $facility_id . "/cdrr/" . $two_current_month_start;
                 $links[] = "facility/" . $facility_id . "/maps/" . $two_current_month_start;
             }
         }
         $username = $this->session->userdata('api_user');
         $password = $this->session->userdata('api_pass');
         $curl->setBasicAuthentication($username, $password);
         $curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE);
     } else {
         $url = $this->nascop_url;
         if (!empty($lists)) {
             $lists = explode(",", $lists[0]);
             foreach ($lists as $facility_id) {
                 if ($type == 0) {
                     $links[] = "sync/facility/" . $facility_id . "/cdrr";
                     $links[] = "sync/facility/" . $facility_id . "/maps";
                 } else {
                     $links[] = "sync/facility/" . $facility_id . "/cdrr/" . $current_month_start;
                     $links[] = "sync/facility/" . $facility_id . "/maps/" . $current_month_start;
                     $links[] = "sync/facility/" . $facility_id . "/cdrr/" . $one_current_month_start;
                     $links[] = "sync/facility/" . $facility_id . "/maps/" . $one_current_month_start;
                     $links[] = "sync/facility/" . $facility_id . "/cdrr/" . $two_current_month_start;
                     $links[] = "sync/facility/" . $facility_id . "/maps/" . $two_current_month_start;
                 }
             }
         }
     }
     //clear orders if its a full sync
     if ($type == 0) {
         $this->clear_orders();
     }
     foreach ($links as $link) {
         $target_url = $url . $link;
         $curl->get($target_url);
         if ($curl->error) {
             $curl->error_code;
             echo "Error: " . $curl->error_code . "<br/>";
         } else {
             $main_array = json_decode($curl->response, TRUE);
             $clean_data = array();
             foreach ($main_array as $main) {
                 if ($main['code'] == "D-CDRR" || $main['code'] == "F-CDRR_units" || $main['code'] == "F-CDRR_packs") {
                     $type = "cdrr";
                 } else {
                     $type = "maps";
                 }
                 if ($type == 0) {
                     if (is_array($main)) {
                         if (!empty($main)) {
                             $id = $this->extract_order($type, array($main), $main['id']);
                         }
                     }
                 } else {
                     if ($main['period_begin'] == $current_month_start || $main['period_begin'] == $one_current_month_start || $main['period_begin'] == $two_current_month_start) {
                         if (is_array($main)) {
                             if (!empty($main)) {
                                 $id = $this->extract_order($type, array($main), $main['id']);
                             }
                         }
                     }
                 }
             }
//.........這裏部分代碼省略.........
開發者ID:OmondiKevin,項目名稱:ADT_MTRH,代碼行數:101,代碼來源:order.php


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