本文整理汇总了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);
}
示例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);
}
示例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']);
}
}
}
}
}
//.........这里部分代码省略.........