当前位置: 首页>>代码示例>>PHP>>正文


PHP get_url_contents函数代码示例

本文整理汇总了PHP中get_url_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP get_url_contents函数的具体用法?PHP get_url_contents怎么用?PHP get_url_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_url_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_info

function get_info()
{
    $get_info = "https://graph.qq.com/user/get_info?" . "access_token=" . $_SESSION['access_token'] . "&oauth_consumer_key=" . $_SESSION["appid"] . "&openid=" . $_SESSION["openid"] . "&format=json";
    $info = get_url_contents($get_info);
    $arr = json_decode($info, true);
    return $arr;
}
开发者ID:ichobits,项目名称:youBBS-ACICFG,代码行数:7,代码来源:qqcallback.php

示例2: add_share

function add_share()
{
    //发布一条动态的接口地址, 不要更改!!
    $url = "https://graph.qq.com/share/add_share?" . "access_token=" . $_SESSION["access_token"] . "&oauth_consumer_key=" . $_SESSION["appid"] . "&openid=" . $_SESSION["openid"] . "&format=json" . "&title=" . urlencode($_REQUEST["title"]) . "&url=" . urlencode($_REQUEST["url"]) . "&comment=" . urlencode($_REQUEST["comment"]) . "&summary=" . urlencode($_REQUEST["summary"]) . "&images=" . urlencode($_REQUEST["images"]);
    //echo $url;
    $ret = get_url_contents($url);
}
开发者ID:omusico,项目名称:wildfire_php,代码行数:7,代码来源:add_share.php

示例3: RunImageSearch

function RunImageSearch($text)
{
    $enc = urlencode($text);
    $imageSearchJson = get_url_contents('http://ajax.googleapis.com/ajax/services/search/images?v=1.0&safe=active&rsz=8&imgsz=medium&q=' . $enc);
    $imageresponse = json_decode($imageSearchJson);
    return $imageresponse;
}
开发者ID:ssainz,项目名称:slack-integration,代码行数:7,代码来源:imageme.php

示例4: qq_callback

function qq_callback()
{
    global $setting;
    if ($_REQUEST['state'] == tcookie('state')) {
        //csrf
        $token_url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&" . "client_id=" . $setting["qqlogin_appid"] . "&redirect_uri=" . urlencode(SITE_URL . "plugin/qqlogin/qq_callback.php") . "&client_secret=" . $setting["qqlogin_key"] . "&code=" . $_REQUEST["code"];
        $response = get_url_contents($token_url);
        if (strpos($response, "callback") !== false) {
            $lpos = strpos($response, "(");
            $rpos = strrpos($response, ")");
            $response = substr($response, $lpos + 1, $rpos - $lpos - 1);
            $msg = json_decode($response);
            if (isset($msg->error)) {
                echo "<h3>error:</h3>" . $msg->error;
                echo "<h3>msg  :</h3>" . $msg->error_description;
                exit;
            }
        }
        $params = array();
        parse_str($response, $params);
        header("Location:" . SITE_URL . "index.php?user/register/" . $params["access_token"]);
    } else {
        echo "The state does not match. You may be a victim of CSRF.";
    }
}
开发者ID:eappl,项目名称:prototype,代码行数:25,代码来源:qq_callback.php

示例5: run_work

function run_work($href)
{
    global $db2, $tablepre;
    $sql = "select * from {$tablepre}collection_content where url = '{$href}'";
    $query = $db2->query($sql);
    $row = $db2->fetch_array($query);
    if ($row) {
        echo "<font color = 'red'>" . $href . "已收集过</font><br>";
        return null;
    } else {
        $from = get_url_contents($href);
        if ($from) {
            preg_match('/charset=\\"?(.*?)\\"/si', $from, $charset);
            if ($charset[1]) {
                $da = new Readability($from, $charset[1]);
                $data = $da->getContent();
                if (preg_match('/(.*?)[_-].*?/si', $data['title'], $title)) {
                    $data['title'] = $title[1];
                }
                if (strlen($data['content']) > 1000) {
                    return $data;
                }
            }
        } else {
            return null;
        }
    }
}
开发者ID:solarpwx,项目名称:Collector,代码行数:28,代码来源:function.php

示例6: list_album

function list_album()
{
    //获取相册列表的接口地址, 不要更改!!
    $url = "https://graph.qq.com/photo/list_album?" . "access_token=" . $_SESSION["access_token"] . "&oauth_consumer_key=" . $_SESSION["appid"] . "&openid=" . $_SESSION["openid"] . "&format=json";
    //echo $url;
    $ret = get_url_contents($url);
    return $ret;
}
开发者ID:caotieshuan,项目名称:ishoutou,代码行数:8,代码来源:list_album.php

示例7: get_openid

function get_openid()
{
    global $db, $tpf, $settings, $timestamp, $onlineip, $user_tpl_dir;
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $_SESSION['access_token'];
    $str = get_url_contents($graph_url);
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str);
    if (isset($user->error)) {
        echo "<h3>error:</h3>" . $user->error;
        echo "<h3>msg  :</h3>" . $user->error_description;
        exit;
    }
    //debug
    //echo("Hello " . $user->openid);
    //set openid to session
    $_SESSION["openid"] = $user->openid;
    if ($_SESSION["openid"]) {
        $arr = get_user_info();
        $nickname = $arr["nickname"];
        $abs_path = '../../../';
        $flid = @$db->result_first("select flid from {$tpf}fastlogin where auth_type='qq' and auth_name='{$_SESSION["openid"]}'");
        if ($flid) {
            $userid = @$db->result_first("select userid from {$tpf}fastlogin where flid='{$flid}'");
            if ($userid) {
                $rs = $db->fetch_one_array("select userid,gid,username,password,email from {$tpf}users where userid='{$userid}'");
                if ($rs) {
                    pd_setcookie('phpdisk_zcore_info', pd_encode("{$rs[userid]}\t{$rs[gid]}\t{$rs[username]}\t{$rs[password]}\t{$rs[email]}"));
                    //login
                    $ins = array('last_login_time' => $timestamp, 'last_login_ip' => $onlineip);
                    $db->query_unbuffered("update {$tpf}users set " . $db->sql_array($ins) . " where userid='{$userid}'");
                    $db->query_unbuffered("update {$tpf}fastlogin set " . $db->sql_array($ins) . " where flid='{$flid}'");
                    //echo 'Login Success';
                    redirect($settings[phpdisk_url] . urr("mydisk", ""), '', 0);
                }
                unset($rs);
            } else {
                // to bind username
                $title = __('bind_disk_name');
                require_once template_echo('pd_fastlogin', $user_tpl_dir);
            }
        } else {
            $ins = array('nickname' => $nickname, 'auth_type' => 'qq', 'auth_name' => $_SESSION["openid"], 'last_login_time' => $timestamp, 'last_login_ip' => $onlineip);
            $db->query_unbuffered("insert into {$tpf}fastlogin set " . $db->sql_array($ins) . "");
            $flid = $db->insert_id();
            //echo 'Login Success';
            $title = __('bind_disk_name');
            require_once template_echo('pd_fastlogin', $user_tpl_dir);
        }
    } else {
        exit('QQ Login Error');
    }
}
开发者ID:saintho,项目名称:phpdisk,代码行数:56,代码来源:qq_callback.php

示例8: is_twitch_online

function is_twitch_online()
{
    $twitch_stream = get_url_contents("https://api.twitch.tv/kraken/streams?channel=" . get_theme_mod('twitch_profile') . "");
    $result = json_decode($twitch_stream, true);
    if ($result['streams'] != null) {
        return true;
    } else {
        return false;
    }
}
开发者ID:ashleah,项目名称:misty,代码行数:10,代码来源:functions.php

示例9: get_html

function get_html($siteurl, $config)
{
    $str = get_url_contents($siteurl);
    $str = str_replace('http://bt.doc5188.com', $config['siteurl'], $str);
    $str = str_replace('优搜磁力搜索', $config['title'], $str);
    $str = str_replace('/statics/', $config['erji'] . 'statics/', $str);
    $str = preg_replace('/<title>([\\s\\S]*?)<\\/title>/i', '<title>' . $config['title'] . ' - 做最全的资源搜索引擎 - 没有搜不到,只有想不到!</title>', $str);
    $str = preg_replace('/<div style="display:none;">([\\s\\S]*?)<\\/div>/i', '<div class="foot">友情链接:' . $config['link'] . '</div><div style="display:none;">' . $config['tongji'] . '</div>', $str);
    $str = str_replace('action="/search"', 'action="' . $config['erji'] . 'search.php"', $str);
    return $str;
}
开发者ID:istrwei,项目名称:ybs_xiaotou,代码行数:11,代码来源:index.php

示例10: getlist

 function getlist($type, $page)
 {
     $url = "http://list.pptv.com/channel_list.html?page={$page}&type={$type}&sort=6";
     $content = get_url_contents($url, 'http://list.pptv.com/');
     preg_match_all('/<a class="ui-list-ct".+href=\'(.+)\\?.+\'.+title="(.+)".+<img.+data-src2="(.+)"/Uis', $content, $matches);
     $list = array();
     foreach ($matches[2] as $k => $v) {
         $list[] = array('title' => $v, 'id' => get_encode($matches[1][$k]), 'pic' => $matches[3][$k], 'actor' => '主演', 'director' => '导演', 'area' => '地方', 'year' => '2015');
     }
     return $list;
 }
开发者ID:Corzcode,项目名称:ims,代码行数:11,代码来源:video_list_xml.php

示例11: AuthCallback_qq

/**
 * 此函数,供Callback处调用,如果返回false,认证失败,否则返回以下哈希表:
 *   last_key  ->  callback得到的last_key
 *   oauth_token ->  上述lastkey中的oauth_token
 *   oauth_token_secret -> 上述lastkey中的oauth_token_secret
 *   user_id -> 用户ID(注意不是QQ号,是QQ的openid)
 *   user_name ->  用户昵称
 *   user_email -> 暂不提供
 */
function AuthCallback_qq()
{
    if ($_REQUEST['state'] == $_SESSION['state']) {
        //csrf
        $token_url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&" . "client_id=" . $_SESSION["appid"] . "&redirect_uri=" . urlencode($_SESSION["callback"]) . "&client_secret=" . $_SESSION["appkey"] . "&code=" . $_REQUEST["code"];
        $response = get_url_contents($token_url);
        if (strpos($response, "callback") !== false) {
            /* $lpos = strpos($response, "(");
               $rpos = strrpos($response, ")");
               $response = substr($response, $lpos + 1, $rpos - $lpos - 1);
               $msg = json_decode($response);
               if (isset($msg->error)) {
               echo "<h3>error:</h3>" . $msg->error;
               echo "<h3>msg  :</h3>" . $msg->error_description;
               exit;
               } */
            return null;
        }
    }
    $params = array();
    parse_str($response, $params);
    //debug
    //print_r($params);
    //set access token to session
    $_SESSION["access_token"] = $params["access_token"];
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $_SESSION['access_token'];
    $str = get_url_contents($graph_url);
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str);
    if (isset($user->error)) {
        return null;
    }
    //debug
    //echo("Hello " . $user->openid);
    //set openid to session
    $_SESSION["openid"] = $user->openid;
    $rtn = array();
    $get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $_SESSION['access_token'] . "&oauth_consumer_key=" . $_SESSION["appid"] . "&openid=" . $_SESSION["openid"] . "&format=json";
    $info = get_url_contents($get_user_info);
    $arr = json_decode($info, true);
    $rtn['user_id'] = $user->openid;
    $rtn['user_name'] = $arr["nickname"];
    //$rtn['user_email'] = $rtn['user_id'] . '@openid_qq';
    //$rtn['user_email'] = 'qqqqq'. '@openid_qq';
    //$rtn['user_id'] = 'aaaaaaa';
    return $rtn;
}
开发者ID:apachesep,项目名称:joomla-weibo,代码行数:60,代码来源:weibo.qq.php

示例12: get_openid

function get_openid()
{
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $_SESSION['access_token'];
    $str = get_url_contents($graph_url);
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str);
    if (isset($user->error)) {
        echo "<h3>error:</h3>" . $user->error;
        echo "<h3>msg  :</h3>" . $user->error_description;
        exit;
    }
    $_SESSION["openid"] = $user->openid;
}
开发者ID:joaosigno,项目名称:dazake-job,代码行数:17,代码来源:qq_callback.php

示例13: priv_joke

 public function priv_joke($line, $args)
 {
     $channel = $line["to"];
     $nick = $line["fromNick"];
     $data = get_url_contents("http://api.icndb.com/jokes/random");
     $data = $data["html"];
     // ICNDB has escaped slashes in JSON response.
     $data = stripslashes($data);
     $joke = json_decode($data);
     if ($joke) {
         if (isset($joke->value->joke)) {
             $this->ircClass->privMsg($channel, html_entity_decode($joke->value->joke));
         }
     } else {
         $this->ircClass->privMsg($channel, "I don't feel like laughing today. :(");
     }
 }
开发者ID:Gulerod,项目名称:php-irc,代码行数:17,代码来源:joke_mod.php

示例14: get_user_info

function get_user_info()
{
    $graph_url = "https://graph.qq.com/user/get_user_info?access_token=" . $_SESSION['access_token'] . "&oauth_consumer_key=" . $_SESSION['appid'] . "&openid=" . $_SESSION['openid'] . "&format=json";
    $str = get_url_contents($graph_url);
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str);
    if (isset($user->error)) {
        echo "<h3>error:</h3>" . $user->error;
        echo "<h3>msg  :</h3>" . $user->error_description;
        exit;
    }
    //debug
    //echo("Hello " . $user->openid);
    //set openid to session
    return $user;
}
开发者ID:caotieshuan,项目名称:ishoutou,代码行数:20,代码来源:qq_callback.php

示例15: get_openid

function get_openid()
{
    global $access_token;
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $access_token;
    $str = get_url_contents($graph_url);
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str);
    if (isset($user->error)) {
        echo "<h3>error:</h3>" . $user->error;
        echo "<h3>msg  :</h3>" . $user->error_description;
        exit;
    }
    //debug
    //echo("Hello " . $user->openid);
    //set openid to session
    $openid = $user->openid;
}
开发者ID:kissthink,项目名称:ym_oauth,代码行数:21,代码来源:qq_callback.php


注:本文中的get_url_contents函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。