Ejemplo n.º 1
0
function s_weibo_http($url, &$params = false, $method = "get")
{
    if (false === $params) {
        $params = array();
    }
    //添加COOKIE
    $params["cookie"]["SUE"] = $_COOKIE["SUE"];
    $params["cookie"]["SUP"] = $_COOKIE["SUP"];
    //添加APPKEY
    $params["source"] = APP_KEY;
    //上传图片
    if (isset($params["pic"]) && is_string($params["pic"]) && substr($params["pic"], 0, 1) === '@') {
        //检查数据是二进制文件还是路径
        $params["_name"] = "pic";
        $params["_data"] = file_get_contents(substr($params["pic"], 1));
        unset($params["pic"]);
    }
    //上传头像
    if (isset($params["image"]) && is_string($params["image"]) && substr($params["image"], 0, 1) === '@') {
        //检查数据是二进制文件还是路径
        $params["_name"] = "image";
        $params["_data"] = file_get_contents(substr($params["image"], 1));
        unset($params["_image"]);
    }
    if (false === ($data = s_http_json($url, $params, $method)) || isset($data["error_code"])) {
        return false;
    }
    return $data;
}
Ejemplo n.º 2
0
function s_badge_http($url, $params = false, $method = 'post')
{
    if (false === $params) {
        $params = array();
    }
    if (false === ($data = s_http_json($url, $params, $method))) {
        return false;
    }
    return $data;
}
Ejemplo n.º 3
0
function s_badge_http($url, $params = false, $method = 'post')
{
    if (false === $params) {
        $params = array();
    }
    //添加APPKEY
    if (isset($params['_APP_KEY'])) {
        $params["source"] = $params['_APP_KEY'];
    } else {
        $params["source"] = APP_KEY;
    }
    //有一些错误码不需要返回false
    if (false === ($data = s_http_json($url, $params, $method)) || isset($data['error']) || isset($data['error_code'])) {
        return s_action_error($data['error'] . ':' . $data['request'], $data['error_code']);
    }
    return $data;
}
Ejemplo n.º 4
0
function s_live_http($url, $params = false, $method = "get")
{
    if (false === $params) {
        $params = array();
    }
    if (false === ($data = s_http_json($url, $params, $method)) || !isset($data['errno']) || $data['errno'] != 1) {
        return false;
    }
    return $data;
}
Ejemplo n.º 5
0
function s_live_http($url, $params = false, $method = "get")
{
    if (false === $params) {
        $params = array();
    }
    if (false === ($data = s_http_json($url, $params, $method))) {
        var_dump($data);
        return false;
    }
    return $data;
}
Ejemplo n.º 6
0
function s_weibo_http($url, $params = false, $method = "get")
{
    if (false === $params) {
        $params = array();
    }
    //添加COOKIE
    $params["cookie"]["SUE"] = $_COOKIE["SUE"];
    $params["cookie"]["SUP"] = $_COOKIE["SUP"];
    //添加APPKEY
    if (isset($params['_APP_KEY'])) {
        $params["source"] = $params['_APP_KEY'];
    } else {
        $params["source"] = APP_KEY;
    }
    //上传图片。有两种情况
    //  1、@/image/web.jpg
    //  2、图片数据
    //
    if (isset($params["pic"]) && is_string($params["pic"])) {
        //检查数据是二进制文件还是路径
        $params["_name"] = "pic";
        if (substr($params["pic"], 0, 1) === '@') {
            //@是路径
            $params["_data"] = file_get_contents(substr($params["pic"], 1));
        } else {
            //直接使用
            $params["_data"] = $params["pic"];
        }
        unset($params["pic"]);
    }
    //上传头像
    if (isset($params["image"]) && is_string($params["image"])) {
        //检查数据是二进制文件还是路径
        $params["_name"] = "image";
        if (substr($params["image"], 0, 1) === '@') {
            //@是路径
            $params["_data"] = file_get_contents(substr($params["image"], 1));
        } else {
            //是图片数据
            $params["_data"] = $params["image"];
        }
        unset($params["image"]);
    }
    //有一些错误码不需要返回false
    if (false === ($data = s_http_json($url, $params, $method)) || isset($data['error']) || isset($data['error_code'])) {
        s_action_error($data['error'] . ':' . $data['request'], $data['error_code']);
        exit($data['error_code']);
    }
    return $data;
}
Ejemplo n.º 7
0
function s_weibo_http($url, $params = false, $method = "get")
{
    if (false === $params) {
        $params = array();
    }
    //添加用户COOKIE
    if (isset($_COOKIE['SUE'])) {
        $params["cookie"]["SUE"] = $_COOKIE["SUE"];
    }
    if (isset($_COOKIE['SUP'])) {
        $params["cookie"]["SUP"] = $_COOKIE["SUP"];
    }
    if (isset($params['token'])) {
        //采用oauth2验证
        $params["access_token"] = $params['token'];
    } else {
        if (isset($params['APP_KEY'])) {
            //指定自己的APPKEY
            $params["source"] = $params['APP_KEY'];
        } else {
            if (defined('APP_KEY')) {
                //采用系统指定的APP_KEY(dev/devinc.common.php指定)
                $params["source"] = APP_KEY;
            }
        }
    }
    //上传图片。有两种情况
    //  1、@/image/web.jpg
    //  2、图片数据
    //
    if (isset($params["pic"]) && is_string($params["pic"])) {
        //检查数据是二进制文件还是路径
        $params["_name"] = "pic";
        if (substr($params["pic"], 0, 1) === '@') {
            //@是路径
            $params["_data"] = file_get_contents(substr($params["pic"], 1));
        } else {
            //直接使用
            $params["_data"] = $params["pic"];
        }
        unset($params["pic"]);
    }
    //上传头像
    if (isset($params["image"]) && is_string($params["image"])) {
        //检查数据是二进制文件还是路径
        $params["_name"] = "image";
        if (substr($params["image"], 0, 1) === '@') {
            //@是路径
            $params["_data"] = file_get_contents(substr($params["image"], 1));
        } else {
            //是图片数据
            $params["_data"] = $params["image"];
        }
        unset($params["image"]);
    }
    //有一些错误码不需要返回false
    if (false === ($data = s_http_json($url, $params, $method)) || isset($data['error']) || isset($data['error_code'])) {
        s_action_error($data['error'] . ':' . $data['request'], $data['error_code']);
        exit($data['error_code']);
    }
    return $data;
}