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


PHP Curl::get_request方法代碼示例

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


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

示例1: get_json_results

 /**
  * Fetch and parse results as though they were a json string.
  *
  * @param String $url    API URL
  * @param Array  $params Array of parameters for the API request
  *
  * @return Array $parts Array of return values
  */
 protected function get_json_results($url, $params = [])
 {
     $this->curl->set_option('CURLOPT_FAILONERROR', FALSE);
     $response = $this->curl->get_request($url . '?' . http_build_query($params));
     $result = json_decode($response->get_result(), TRUE);
     if ($response->http_code !== 200) {
         $context = ['message' => $result['message'], 'request' => $url, 'id' => $result['sys']['id']];
         $this->logger->warning('Contentful API Request ({request}) failed with id "{id}": {message}', $context);
         $result['total'] = 0;
     }
     unset($response);
     return $result;
 }
開發者ID:rubendgr,項目名稱:lunr,代碼行數:21,代碼來源:DeliveryApi.php

示例2: get_json_results

 /**
  * Fetch and parse results as though they were a query string.
  *
  * @param String $url    API URL
  * @param Array  $params Array of parameters for the API request
  * @param String $method Request method to use, either 'get' or 'post'
  *
  * @return Array $result Array of return values
  */
 protected function get_json_results($url, $params = [], $method = 'get')
 {
     if (strtolower($method) === 'get') {
         $response = $this->curl->get_request($url . '?' . http_build_query($params));
     } else {
         $response = $this->curl->post_request($url, $params);
     }
     $result = json_decode($response->get_result(), TRUE);
     if ($response->http_code !== 200) {
         $error = $result['errors'][0];
         $context = ['message' => $error['message'], 'code' => $error['code'], 'request' => $url];
         $this->logger->error('Twitter API Request ({request}) failed, ({code}): {message}', $context);
         $result = '';
     }
     unset($response);
     return $result;
 }
開發者ID:rubendgr,項目名稱:lunr,代碼行數:26,代碼來源:Api.php

示例3: dirname

# limitations under the License.
*/
require_once dirname(__DIR__) . "/classes/Requires.php";
//Get settings
$result = MySQLQueries::get_settings();
$row = MySQLConnection::fetch_object($result);
$instance_key = null;
if (isset($row->data)) {
    $row->data = json_decode($row->data);
    if (isset($row->data->instance_key) && !empty($row->data->instance_key)) {
        $instance_key = $row->data->instance_key;
    } else {
        $instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
        $data = array("instance_key" => $instance_key, "default_ssh_username" => $row->data->default_ssh_username, "default_ssh_port" => $row->data->default_ssh_port, "default_interpreter" => $row->data->default_interpreter, "timezone_offset" => $row->data->timezone_offset, "timezone_daylight_savings" => $row->data->timezone_daylight_savings);
        MySQLQueries::edit_settings(json_encode((object) $data));
    }
} else {
    $instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
    $data = array("instance_key" => $instance_key);
    MySQLQueries::edit_settings(json_encode((object) $data));
}
$servers = array();
$result = MySQLQueries::get_servers();
while ($row = MySQLConnection::fetch_object($result)) {
    $servers[] = $row;
}
$payload = '{"event":"' . $instance_key . '","properties":{"token":"678f0669ff58d890eeb50633c91a633d","distinct_id":"' . $instance_key . '","ip":"' . Functions::get_remote_ip() . '","servers":"' . count($servers) . '","version":"' . Version::app . '","ip-address":"' . Functions::get_remote_ip() . '","mp_name_tag":"' . $instance_key . '","time":"' . time() . '"}}';
$curl = new Curl();
$curl->get_request("https://api.mixpanel.com/track/?data=" . base64_encode($payload));
$curl->close();
echo '{"instance_key":"' . $instance_key . '"}';
開發者ID:tsing,項目名稱:commando,代碼行數:31,代碼來源:metrics.php


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