本文整理汇总了PHP中Http::curlDownload方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::curlDownload方法的具体用法?PHP Http::curlDownload怎么用?PHP Http::curlDownload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::curlDownload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callbackLogin
public function callbackLogin($request_args)
{
try {
$user = $this->_om->getUserInfo($request_args);
} catch (Exception $e) {
header("Content-Type: text/html; charset=utf-8");
exit("<script>alert('第三方登录权限有问题');window.location.href='" . u('user/login') . "';</script>");
}
$bind_user = $this->_checkBind($this->_type, $user['keyid']);
if ($bind_user) {
$this->_updateBindInfo($user);
$user_info = D('user')->field('id,username')->where(array('id' => $bind_user['uid']))->find();
$this->_oauth_visitor()->assign_info($user_info);
return U('user/index');
} else {
if (D('user')->where(array('username' => $user['keyname']))->count()) {
$user['pin_user_name'] = $user['keyname'] . '_' . mt_rand(99, 9999);
} else {
$user['pin_user_name'] = $user['keyname'];
}
$user['pin_user_name'] = urlencode($user['pin_user_name']);
$user['keyname'] = urlencode($user['keyname']);
if ($user['keyavatar_big']) {
$user['temp_avatar'] = '';
$avatar_temp_root = C('pin_attach_path') . 'avatar/temp/';
$temp_dir = date('ymd', time()) . '/';
$file_name = date('ymdhis' . mt_rand(1000, 9999)) . '.jpg';
mkdir($avatar_temp_root . $temp_dir);
$image_content = Http::curlDownload($user['keyavatar_big'], $avatar_temp_root . $temp_dir . $file_name);
$user['temp_avatar'] = $temp_dir . $file_name;
}
$user['type'] = $this->_type;
cookie('user_bind_info', $user);
return U('user/binding');
}
}
示例2: get_wxinfo
public function get_wxinfo()
{
import("@.ORG.Wxhelper");
$helper = new Wxhelper($this->pubwechat);
$db = M('wechat_user');
$uid = I('get.id');
//查询用户信息
$info = $db->find($uid);
//获取用户微信资料
$return = $helper->get_user_info($info['wechatid']);
if ($return['errcode']) {
echo "获取失败,错误信息:{errcode:{$return['errcode']},errmsg:{$return['errmsg']}}";
die;
} elseif (!empty($return['headimgurl'])) {
//下载微信头像
import("@.ORG.Http");
import('@.ORG.Image.ThinkImage');
$headimg = "./Data/upload/headimg/" . $uid . '.jpg';
if (!is_file($headimg) || filesize($headimg) == 0) {
//下载图片
Http::curlDownload($return['headimgurl'], $headimg);
$return['headimgurl'] = $headimg;
}
//保存用户最新微信资料
$wxdata = array('subscribe' => $return['subscribe'], 'nickname' => $return['nickname'], 'sex' => $return['sex'], 'city' => $return['city'], 'province' => $return['province'], 'headimgurl' => $headimg, 'subscribe_time' => $return['subscribe_time']);
$db->where(array('id' => $uid))->save($wxdata);
$href = U('index', array('p' => I('get.p', 1), 'group_id' => I('get.group_id')));
echo "获取微信资料成功,请<a href='{$href}'>刷新</a>页面查看!";
} else {
echo "获取微信资料成功!";
}
}
示例3: weixin_download
public function weixin_download()
{
import("ORG.Net.Http");
// 这里下载的文件会在微信服务器上保存三天,也许微信在瞎扯淡
// 暂时使用post,改用jsonp
$callback = $_GET['callback'];
$wx_medias = $_GET['media_ids'];
$wx_medias_arr = explode(',', $wx_medias);
// echo $wx_medias;
// 微信api接口调用令牌,有效期为7200秒,过了这个时间就必须重新获得。
$access_token = 'QFJNCU4fE-KiSyJse3gXQ8Qzj0KW5qVhCieAOePKeuZN2gO16L-Gp2oaGwG5m6MnXEIoLfl70gd9Q-oG2XEnMSTwtSlfh5XHvZS59fmae9w';
$wxdown_dir = './wx_media/';
// 微信文件保存目录
// 循环下载文件
$return_files = array();
foreach ($wx_medias_arr as $wx_media_id) {
// 微信服务器上面的下载地址
$wxdown_url = 'http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=' . $access_token . '&media_id=' . $wx_media_id;
// 本地文件名,包含后缀
$local_name = $wx_media_id . '.jpg';
// 本地路径,使用的相对路径
$local_path = $wxdown_dir . $local_name;
// 如果文件存在就不下载
if (file_exists($local_path)) {
continue;
} else {
// 下载文件
Http::curlDownload($wxdown_url, $local_path);
// 组成新的网址,准备返回给客户端
$return_url = $_SERVER['SERVER_NAME'] . $local_path;
$return_url = str_replace('./', '/', $return_url);
$return_files[] = $return_url;
}
}
// $wxdown_url = 'http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=QFJNCU4fE-KiSyJse3gXQ8Qzj0KW5qVhCieAOePKeuZN2gO16L-Gp2oaGwG5m6MnXEIoLfl70gd9Q-oG2XEnMSTwtSlfh5XHvZS59fmae9w&media_id=RYR7gU27yIhEiUO8m1CD9S0lbZrOAFgGb6y3xnx_rJg5lt0a2h312ay16T4_T-EX';
// $wxdown_dir = './wx_media/'; // 微信文件保存目录
// echo __DIR__;
// Http::curlDownload($wxdown_url, $wxdown_dir . "xg.jpg");
// 记录
file_put_contents('abc.txt', $wx_medias);
// 组成了jsonp
$return_json = $callback . '(' . json_encode($return_files) . ')';
echo $return_json;
}