Пример #1
0
function s_string_face(&$weibo)
{
    if (s_bad_string($weibo)) {
        return false;
    }
    //获取表情列表
    $mkey = 'face_get';
    if (!($rep = s_memcache($mkey))) {
        //未在缓存中存在
        if ($rep = s_http_response('https://api.weibo.com/2/emotions.json?source=1362404091&_=1365667265344')) {
            //缓存1天
            s_memcache($mkey, $rep, 86400);
        }
    }
    //    $json = json_decode($rep);
    return $weibo;
    //return preg_replace("/\#(.*)\#/iUs", "<a href=\"http://s.weibo.com/weibo/$1\" target=\"_blank\">$0</a>", $weibo);
}
Пример #2
0
function s_http_json($url, &$params = false, $method = "get")
{
    if (s_bad_string($url) || false === ($response = s_http_response($url, $params, $method))) {
        return false;
    }
    return json_decode($response, true);
}
Пример #3
0
function s_weibo_http($url, &$params = false, $method = 'get', $mutil = false)
{
    if (false === $params) {
        $params = array();
    }
    if (empty($params['access_token'])) {
        //采用系统指定的APP_KEY(dev/devinc.common.php指定)
        $params["source"] = isset($params['APP_KEY']) ? $params['APP_KEY'] : APP_KEY;
    }
    //获取本地cookie
    foreach ($_COOKIE as $key => $value) {
        $cookies[] = $key . "=" . rawurlencode($value);
    }
    $header = array();
    $header[] = 'Cookie: ' . implode('; ', $cookies);
    $header[] = 'Referer: ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
    $header[] = 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'];
    //有一些错误码不需要返回false
    if (false === ($response = s_http_response($url, $params, $method, $mutil, $header, false)) || false === ($json = json_decode($response, true))) {
        s_action_error($json['error'], $json['error_code']);
        exit($json['error_code']);
    }
    return $json;
}