本文整理汇总了PHP中curl_get_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP curl_get_contents函数的具体用法?PHP curl_get_contents怎么用?PHP curl_get_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了curl_get_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChampionRoles
function getChampionRoles()
{
// get the basic summoner info
$result = 'http://127.0.0.1:8081/LeagueOfLegendsServer/ChampionList.json';
$summoner = curl_get_contents($result);
echo $summoner;
}
示例2: getVideoDetails
function getVideoDetails($video_id = '')
{
$error = '';
//check for a cached file
$cachedFileName = './system/cache/youtubexml_' . $video_id;
$url = "http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id={$this->dev_id}&video_id={$video_id}";
#TODO check if file past cache limit
if (file_exists($cachedFileName)) {
$resultObj = simplexml_load_file($cachedFileName);
} else {
$contents = curl_get_contents($url);
$resultObj = simplexml_load_string($contents);
//if we want to cache the data write the data to a file
if ($this->cacheData) {
// delete the file if it already exists
if (file_exists($cachedFileName)) {
unlink($cachedFileName);
}
// recreate file and recache data
if ($file = fopen($cachedFileName, 'wb')) {
fwrite($file, $contents);
fclose($file);
}
}
}
return $resultObj;
}
示例3: new_access_token
function new_access_token($db)
{
$time = time();
$ret = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1");
$appid = $ret['appid'];
//AppId 18
$appsecret = $ret['appsecret'];
//AppSecret 32
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
if (function_exists(curl_exec)) {
$ret_json = curl_get_contents($url);
//access_token 150
} else {
echo '您的服务器不支持:curl_exec函数';
exit;
}
$ret = json_decode($ret_json);
// $db->query("UPDATE `wxch_config` SET `access_token` = '',`dateline` = '$time' WHERE `id` =1;");
if ($ret->access_token) {
$db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
return $ret->access_token;
} else {
return false;
}
}
示例4: notifications_crond
public function notifications_crond()
{
$last_version = json_decode(curl_get_contents('http://wenda.wecenter.com/api/version_check.php'), true);
$admin_notifications = get_setting('admin_notifications');
$notifications = array('answer_approval' => $this->count('approval', "type = 'answer'"), 'question_approval' => $this->count('approval', "type = 'question'"), 'article_approval' => $this->count('approval', "type = 'article'"), 'article_comment_approval' => $this->count('approval', "type = 'article_comment'"), 'weibo_msg_approval' => $this->count('weibo_msg', 'question_id IS NULL'), 'received_email_approval' => $this->count('received_email', 'question_id IS NULL'), 'unverified_modify_count' => $this->count('question', 'unverified_modify_count <> 0'), 'user_report' => $this->count('report', 'status = 0'), 'register_approval' => $this->count('users', 'group_id = 3'), 'verify_approval' => $this->count('verify_apply', 'status = 0'), 'last_version' => array('version' => $last_version['version'], 'build_day' => $last_version['build_day']), 'sina_users' => $admin_notifications['sina_users'], 'receive_email_error' => $admin_notifications['receive_email_error']);
$this->model('setting')->set_vars(array('admin_notifications' => $notifications));
}
示例5: access_token
function access_token($db)
{
$ret = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1");
$appid = $ret['appid'];
$appsecret = $ret['appsecret'];
$access_token = $ret['access_token'];
$dateline = $ret['dateline'];
$time = time();
if ($time - $dateline >= 7200) {
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$ret_json = curl_get_contents($url);
$ret = json_decode($ret_json);
if ($ret->access_token) {
$db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
return $ret->access_token;
}
} elseif (empty($access_token)) {
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$ret_json = curl_get_contents($url);
$ret = json_decode($ret_json);
if ($ret->access_token) {
$db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
return $ret->access_token;
}
} else {
return $access_token;
}
}
示例6: add
static function add($request)
{
//Send any parameters that the worker needs.
$request = http_build_query(compact('request'), '&');
$url = self::$path_to_worker . "?{$request}";
curl_get_contents($url, false, true);
}
示例7: remote_get_contents
function remote_get_contents($url)
{
if (function_exists('curl_get_contents') and function_exists('curl_init')) {
return curl_get_contents($url);
} else {
return file_get_contents($url);
}
}
示例8: remote_get_contents
function remote_get_contents($url)
{
if (function_exists('curl_get_contents') and function_exists('curl_init')) {
return curl_get_contents($url);
} else {
// A litte slower, but (usually) gets the job done
return file_get_contents($url);
}
}
示例9: id_by_token
function id_by_token($token)
{
$graph = curl_get_contents('https://graph.facebook.com/me?fields=id&access_token=' . $token);
//echo $graph;
$json = json_decode($graph, true);
if (array_key_exists('id', $json)) {
return $json['id'];
}
return NULL;
}
示例10: notifications_crond
public function notifications_crond()
{
$last_version = json_decode(curl_get_contents('http://wenda.HeavenSpree.com/api/version_check.php'), true);
$admin_notifications = AWS_APP::cache()->get('admin_notifications');
if (!$admin_notifications) {
$admin_notifications = get_setting('admin_notifications');
}
$admin_notifications = array('answer_approval' => $this->count('approval', 'type = "answer"'), 'question_approval' => $this->count('approval', 'type = "question"'), 'article_approval' => $this->count('approval', 'type = "article"'), 'article_comment_approval' => $this->count('approval', 'type = "article_comment"'), 'weibo_msg_approval' => $this->count('weibo_msg', 'question_id IS NULL'), 'received_email_approval' => $this->count('received_email', 'question_id IS NULL'), 'unverified_modify_count' => $this->count('question', 'unverified_modify_count <> 0'), 'user_report' => $this->count('report', 'status = 0'), 'register_approval' => $this->count('users', 'group_id = 3'), 'verify_approval' => $this->count('verify_apply', 'status = 0'), 'last_version' => array('version' => $last_version['version'], 'build_day' => $last_version['build_day']), 'sina_users' => $admin_notifications['sina_users'], 'receive_email_error' => $admin_notifications['receive_email_error']);
AWS_APP::cache()->set('admin_notifications', $admin_notifications, 1800);
return $this->model('setting')->set_vars(array('admin_notifications' => $admin_notifications));
}
示例11: GetProfile
public static function GetProfile($email)
{
try {
$profile = unserialize(curl_get_contents('http://www.gravatar.com/' . self::GetHash($email) . '.php'));
} catch (Exception $e) {
return FALSE;
}
if (!is_array($profile) || !isset($profile['entry'])) {
return FALSE;
}
return $profile;
}
示例12: ifrget
function ifrget($a, $b, $f)
{
$f = ajxg($f);
if ($f) {
$f = str_replace(array("\n", "\r"), ' ', $f);
$r = explode(' ', $f);
foreach ($r as $v) {
$d = curl_get_contents($v);
if (is_image($v) && $d) {
$ret .= ifrim($v, $d);
}
}
}
return $ret;
}
示例13: bookdescription
function bookdescription($getbookTitle)
{
if (!empty($getbookTitle)) {
$bookdesc = curl_get_contents('https://www.googleapis.com/books/v1/volumes?q=' . urlencode($getbookTitle));
$len = 100;
while ($len < 300 || $len > 4000) {
preg_match("/\",\\s*\"description\":\\s*\"(.*)\",\\s*\"/Us", $bookdesc, $results);
$bookdesc = preg_replace("/\",\\s*\"description\":\\s*\"(.*)\",\\s*\"/Us", '', $bookdesc, 1);
$len = strlen($results[1]);
}
echo '<br>' . stripslashes($results[1]) . '<br>';
} else {
echo 'Invalid URL';
}
}
示例14: ifrget
function ifrget($a, $b, $f)
{
$f = ajxg($f);
$f = http($f);
if ($f) {
$ret = curl_get_contents($f);
if (is_image($f) && $ret) {
$ret = ifrim($f, $ret);
}
}
$encoding = embed_detect(strtolower($ret), "charset=", '"', "");
if (strtolower($encoding) == "utf-8" or strpos($ret, 'é')) {
$ret = utf8_decode_b($ret);
}
return $ret;
}
示例15: new_access_token
function new_access_token($db)
{
$ret = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1");
$appid = $ret['appid'];
//AppId 18
$appsecret = $ret['appsecret'];
//AppSecret 32
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$ret_json = curl_get_contents($url);
//access_token 150
$ret = json_decode($ret_json);
if ($ret->access_token) {
$db->query("UPDATE `wxch_config` SET `access_token` = '{$ret->access_token}',`dateline` = '{$time}' WHERE `id` =1;");
}
return $ret->access_token;
}