本文整理汇总了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;
}
示例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;
}
示例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 . '"}';