upload() 공개 메소드

发表图片微博消息。目前上传图片大小限制为<5M。
注意:lat和long参数需配合使用,用于标记发表微博消息时所在的地理位置,只有用户设置中geo_enabled=true时候地理位置信息才有效。
对应API:{@link http://open.weibo.com/wiki/2/statuses/upload statuses/upload}
public upload ( string $status, string $pic_path, float $lat = NULL, float $long = NULL, integer $visible ) : array
$status string 要更新的微博信息。信息内容不超过140个汉字, 为空返回400错误。
$pic_path string 要发布的图片路径, 支持url。[只支持png/jpg/gif三种格式, 增加格式请修改get_image_mime方法]
$lat float 纬度,发表当前微博所在的地理位置,有效范围 -90.0到+90.0, +表示北纬。可选。
$long float 可选参数,经度。有效范围-180.0到+180.0, +表示东经。可选。
$visible integer 微博的可见性,0:所有人能看,1:仅自己可见,2:密友可见,3:指定分组可见,默认为0
리턴 array
예제 #1
0
파일: sina.php 프로젝트: kid2682/SMZDM
 /**
  * 推送信息
  */
 public function send($bind_user, $data)
 {
     $info = unserialize($bind_user['info']);
     $client = new SaeTClientV2($this->setting['app_key'], $this->setting['app_secret'], $info['access_token']);
     try {
         isset($data['url']) && ($data['content'] = $data['content'] . $data['url']);
         if (isset($data['img']) && !empty($data['img'])) {
             return $client->upload($data['content'], $data['img']);
         } else {
             return $client->update($data['content']);
         }
     } catch (Exception $e) {
     }
 }
예제 #2
0
 /**
  * 新浪微博分享
  */
 function sina()
 {
     $this->type = 'SINA';
     $this->getConfig();
     //判断新浪微博是否已经登陆
     if (!empty($this->token)) {
         $_SESSION['sina_token'] = $this->token;
         vendor("sina.sina");
         $c = new \SaeTClientV2($this->AppKey, $this->AppSecret, $_SESSION['sina_token']['access_token']);
         $sharecomment = "{$_REQUEST['sharecomment']}http://" . $_SERVER['HTTP_HOST'] . "/Portal/{$this->table}/info/id/{$this->id}";
         $sharecomment = urlencode($sharecomment);
         $ret = $c->upload($sharecomment, 'http://' . $_SERVER['HTTP_HOST'] . $_REQUEST['picurl']);
         //$ret = $c->upload( $_REQUEST['sharecomment'],'http://'.$_SERVER['HTTP_HOST'].$_REQUEST['picurl']);
         if (isset($ret['error_code']) && $ret['error_code'] > 0) {
             echo "<p>发送失败,错误:{$ret['error_code']}:{$ret['error']}</p>";
         } else {
             $this->share();
         }
         exit;
     }
     $this->callback .= "/sharecomment/{$_REQUEST['sharecomment']}/picurl/{$_REQUEST['picurl']}";
     if (isset($_REQUEST['code'])) {
         //获取accessToken
         $keys = array();
         $keys['code'] = $_REQUEST['code'];
         $keys['redirect_uri'] = $this->callback;
         try {
             vendor("sina.sina");
             $o = new \SaeTOAuthV2($this->AppKey, $this->AppSecret);
             $this->token = $o->getAccessToken('code', $keys);
         } catch (\OAuthException $e) {
             exit($e->getMessage());
         }
     } else {
         //新浪微博登陆
         $this->OAuthor();
     }
     //判断是否授权成功
     if ($this->token) {
         $_SESSION['sina_token'] = $this->token;
         header("Content-type:text/html;charset=utf-8");
         echo "新浪微博登陆成功,请重新分享";
     } else {
         exit("授权失败!");
     }
 }
예제 #3
0
 /**
  * sinaweibo上传图片并发布一条新微博
  */
 public function addSinaWeiboUpload($bindinfo, $params)
 {
     include_once BASE_DATA_PATH . DS . 'api' . DS . 'snsapi' . DS . 'sinaweibo' . DS . 'config.php';
     include_once BASE_DATA_PATH . DS . 'api' . DS . 'snsapi' . DS . 'sinaweibo' . DS . 'saetv2.ex.class.php';
     $c = new SaeTClientV2(C('share_sinaweibo_appid'), C('share_sinaweibo_appkey'), $bindinfo['snsbind_accesstoken']);
     if ($params['images']) {
         $c->upload($params['title'] . $params['comment'] . $params['url'], $params['images']);
     } else {
         $c->update($params['title'] . $params['comment'] . $params['url']);
     }
 }
예제 #4
0
 /**
  * 新浪微博分享
  *
  * @param	array	$data
  * @return  Bool|String
  */
 public function _execute_sinashare($data)
 {
     $data = dr_string2array($data);
     if (!$data) {
         return '执行值不存在';
     }
     $config = (require FCPATH . 'config/oauth.php');
     if (!isset($config['sina']) || !isset($config['sina']['key'])) {
         return 'Sina配置文件不正确或者Key不存在';
     }
     // 查询OAuth2授权信息
     $auth = $this->db->where('uid', (int) $data['uid'])->where('oauth', 'sina')->limit(1)->get('member_oauth')->row_array();
     if (!$auth) {
         return '会员uid:' . $data['uid'] . ' 授权信息不存在';
     }
     require_once FCPATH . 'dayrui/libraries/Share/Sina.php';
     $auth = new SaeTClientV2($config['sina']['key'], $config['sina']['secret'], $auth['access_token']);
     if ($data['thumb']) {
         $call = $auth->upload(dr_strcut($data['title'], 120) . ' ' . $data['url'], $data['thumb']);
     } else {
         $call = $auth->update(dr_strcut($data['title'], 120) . ' ' . $data['url']);
     }
     return isset($call['id']) && $call['id'] ? TRUE : (isset($call['error']) && $call['error'] ? $call['error'] : $call);
 }
예제 #5
0
function Sina($data)
{
    require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php';
    $uid = intval($GLOBALS['user_info']['id']);
    $udata = $GLOBALS['db']->getRow("select sina_token from " . DB_PREFIX . "user where id = " . $uid);
    $client = new SaeTClientV2($GLOBALS['m_config']['sina_app_key'], $GLOBALS['m_config']['sina_app_secret'], $udata['sina_token']);
    if (empty($data['img'])) {
        $msg = $client->update($data['content']);
    } else {
        $msg = $client->upload($data['content'], $data['img']);
    }
    if ($msg['error']) {
        $result['status'] = false;
        $result['code'] = $msg['error_code'];
    } else {
        $result['status'] = true;
        $result['code'] = 0;
    }
    return $result;
}
예제 #6
0
파일: deal.php 프로젝트: momoim/momo-api
 /**
  * 
  * @param $uid
  * @param $site
  * @param $content
  * @param $image
  * @return unknown_type
  */
 private function _sync_weibo($sync, $uid, $site, $title, $description, $image, $location)
 {
     $res = array();
     if (is_array($sync) && count($sync) > 0 && $title && $description && $image) {
         if ($sync['weibo']) {
             require_once Kohana::find_file('vendor', 'weibo/saetv2.ex.class');
             $oauth = Kohana::config('uap.oauth');
             $token = Bind_Model::instance()->oauth2_check($uid, 'weibo');
             $updated_time = $token['updated'] ? $token['updated'] : $token['created'];
             if ($updated_time + $token['expires_in'] > time()) {
                 $c = new SaeTClientV2($oauth['weibo.com']['WB_AKEY'], $oauth['weibo.com']['WB_SKEY'], $token['access_token']);
                 if ($c) {
                     $img = $this->model->_warp_image($image);
                     $img_url = $img[0]['url'] ? $img[0]['url'] : '';
                     $content = '#' . $title . '#' . $description;
                     $content = str::strLen($content) > 120 ? str::cnSubstr($content, 0, 120) . '..' : $content;
                     //$img_url = 'http://momoimg.com/photo/3846870_LrurOnCRM365Gc_cI0ferPZaqFP2hLDtdsB2R1WtHFsrGiLDQ647LfN09AM_780.jpg';
                     $latitude = $location['latitude'] ? $location['latitude'] : NULL;
                     $longitude = $location['longitude'] ? $location['longitude'] : NULL;
                     if ($img_url) {
                         $result = $c->upload($content, $img_url, $latitude, $longitude);
                     } else {
                         $result = $c->update($content, $latitude, $longitude);
                     }
                     if ($result['id']) {
                         $res = array('weibo' => 1);
                     } else {
                         $res = array('weibo' => 0, 'error' => $result['error'], 'type' => 'error');
                     }
                 }
             } else {
                 $res = array('weibo' => 0, 'error' => 'access_token expired!', 'type' => 'expire');
             }
         }
     }
     return $res;
 }
예제 #7
0
파일: function.php 프로젝트: omusico/jianli
function yjl_uwb($u, $c, $i, $e = '', $p = '')
{
    global $r_main, $yjl_tpath, $dbprefix, $yjl_url, $yjl_isdebug;
    if ($yjl_isdebug == 0) {
        if (trim($r_main['sina_k']) != '' && trim($r_main['sina_s']) != '') {
            $q_rex = sprintf('select profile, access_token from %s where uid=%s and length(access_token)>0 limit 1', $dbprefix . 'xwb_bind_info', $u);
            $rex = mysql_query($q_rex) or die(mysql_error());
            $r_rex = mysql_fetch_assoc($rex);
            if (mysql_num_rows($rex) > 0) {
                $a_xwb = json_decode($r_rex['profile'], true);
                if (isset($a_xwb['bind_setting']) && $a_xwb['bind_setting'] == 1) {
                    require_once $e . 'lib/saetv2.ex.class.php';
                    $so = new SaeTClientV2($r_main['sina_k'], $r_main['sina_s'], $r_rex['access_token']);
                    if ($p != '') {
                        $rs = $so->upload($c, $e . $p);
                    } else {
                        $rs = $so->update($c);
                    }
                    if (isset($rs['mid']) && $rs['mid'] != '') {
                        $iSQL = sprintf('insert into %s (tid, mid) values (%s, %s)', $dbprefix . 'xwb_bind_topic', $i, $rs['mid']);
                        $result = mysql_query($iSQL) or die(mysql_error());
                    }
                }
            }
            mysql_free_result($rex);
        }
        if (trim($r_main['tqq_k']) != '' && trim($r_main['tqq_s']) != '') {
            $q_rex = sprintf('select token, tsecret from %s where uid=%s and length(token)>0 and length(tsecret)>0 and synctoqq>0 limit 1', $dbprefix . 'qqwb_bind_info', $u);
            $rex = mysql_query($q_rex) or die(mysql_error());
            $r_rex = mysql_fetch_assoc($rex);
            if (mysql_num_rows($rex) > 0) {
                require_once $e . 'lib/tqq_opent.php';
                require_once $e . 'lib/tqq_client.php';
                $tqq = new MBApiClient($r_main['tqq_k'], $r_main['tqq_s'], $r_rex['token'], $r_rex['tsecret']);
                $tqq_a = array('c' => $c, 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'type' => 1);
                if ($p != '') {
                    $ps = getimagesize($p);
                    $p_data = file_get_contents($p);
                    $tqq_a['p'] = array($ps['mime'], $p, $p_data);
                }
                $rq = $tqq->postOne($tqq_a);
                if (isset($rq['data']['id']) && $rq['data']['id'] != '') {
                    $iSQL = sprintf('insert into %s (tid, qqwb_id) values (%s, %s)', $dbprefix . 'qqwb_bind_topic', $i, $rq['data']['id']);
                    $result = mysql_query($iSQL) or die(mysql_error());
                }
            }
            mysql_free_result($rex);
        }
    }
}
예제 #8
0
    public function sendwb()
    {
        // 获取消息正文 发晒单 bask 写心情 mood
        /*
         * if(isset($this->request->post['bask']) && ($this->request->post['bask'])) { $message_text = $this->request->post['bask']; $message_flag = 1; } else if(isset($this->request->post['mood']) && ($this->request->post['mood'])) { $message_text = $this->request->post['mood']; $message_flag = 2; } else { $message_text = ''; $message_flag = 0; } //获取图片url地址 $this->session->data['token'] if(isset($this->request->post['image']) && ($this->request->post['image'])) { $imgurl = $this->request->post['image']; } else { $imgurl = ''; } //获取视频url地址 if(isset($this->reuqest->post['video']) && ($this->request->post['video'])) { $videourl = $this->request->post['video']; } else { $videourl = ''; } //之前已经登录微博并授权 if (isset($_SESSION['token'])) { } //未登录微博授权 else { include_once(DIR_SYSTEM . 'weibo/config.php'); include_once(DIR_SYSTEM . 'weibo/saetv2.ex.class.php'); if (isset($_GET['code'])) { $keys = array(); $keys['code'] = $_GET['code']; $keys['redirect_uri'] = WBS_CALLBACK_URL; try { $token = $o->getAccessToken('code', $keys); } catch (OAuthException $e) { } } else { echo "<script language=\"javascript\">window.open ('https://api.weibo.com/oauth2/authorize?client_id=".WB_AKEY."&redirect_uri=".WBS_CALLBACK_URL."&response_type=code','newwindow','height=440,width=630,top=150,left=300,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no')</script>"; } }
         */
        include_once DIR_SYSTEM . 'weibo/config.php';
        include_once DIR_SYSTEM . 'weibo/saetv2.ex.class.php';
        $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
        // 之前未登录微博授权
        if (isset($_GET['code'])) {
            $keys = array();
            $keys['code'] = $_GET['code'];
            $keys['redirect_uri'] = WBS_CALLBACK_URL;
            try {
                $token = $o->getAccessToken('code', $keys);
                // $this->session->data['token'] = $token;
            } catch (OAuthException $e) {
            }
        }
        if (isset($token) && !empty($token)) {
            $this->session->data['token'] = $token;
            $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
            $ms = $c->home_timeline();
            // done
            $uid_get = $c->get_uid();
            /*
             * var_dump($token); var_dump($uid_get);
             */
            $uid = $uid_get['uid'];
            $user_message = $c->show_user_by_id($uid);
            // 根据ID获取用户等基本信息
            // 图片微博
            if (isset($this->session->data['wb']['imgurl'])) {
                $ret = $c->upload($this->session->data['wb']['message_text'] . ' @信恩世通CNstorm', $this->session->data['wb']['imgurl']);
            } else {
                // 文字微博
                $ret = $c->update($this->session->data['wb']['message_text'] . ' @信恩世通CNstorm');
            }
            // 返回信息
            $msg = '';
            if (isset($ret['error_code']) && $ret['error_code'] > 0) {
                $err = '微博同步失败,';
                if ($ret['error_code'] == 20003) {
                    $msg = $err . "用户不存在";
                } elseif ($ret['error_code'] == 20005) {
                    $msg = $err . "目前仅支持JPG、GIF、PNG的图片";
                } elseif ($ret['error_code'] == 20006) {
                    $msg = $err . "图片太大";
                } elseif ($ret['error_code'] == 20012) {
                    $msg = $err . "输入文字太长,请不要超过140字";
                } elseif ($ret['error_code'] == 20015) {
                    $msg = $err . "账号、IP或应用非法,暂时无法完成此操作";
                } elseif ($ret['error_code'] == 20016) {
                    $msg = $err . "发布内容过于频繁";
                } elseif ($ret['error_code'] == 20017) {
                    $msg = $err . "提交相似的信息";
                } elseif ($ret['error_code'] == 20018) {
                    $msg = $err . "包含非法网址";
                } elseif ($ret['error_code'] == 20019) {
                    $msg = $err . "提交相同的信息";
                } elseif ($ret['error_code'] == 20020) {
                    $msg = $err . "包含广告信息";
                } elseif ($ret['error_code'] == 20021) {
                    $msg = $err . "包含非法内容";
                } elseif ($ret['error_code'] == 20022) {
                    $msg = $err . "此IP地址上的行为异常";
                } elseif ($ret['error_code'] == 20032) {
                    $msg = "发布成功,目前服务器可能会有延迟,请耐心等待1-2分钟";
                } else {
                    $msg = "微博同步失败";
                }
            } else {
                unset($this->session->data['wb']['message_text']);
                if (isset($this->session->data['wb']['imgurl'])) {
                    unset($this->session->data['wb']['imgurl']);
                }
                $msg = "微博同步成功";
            }
            echo <<<Eof
<script type="text/javascript">  
  var i = 3;
  function check(){
       if(i>0){
            i = i - 1;
            document.getElementById("time").innerHTML = i;
            setTimeout("check()",1000);
         }else{
          window.opener = null;
          window.close();
         }
   }
     setTimeout("check()",1000);
  
  </script>
  
  <body>
     <div><p>{$msg}</p></div>

     <div>本页面<span id="time">3</span>秒后自动关闭</div>

     <div><p><a href="http://www.weibo.com/" target="_blank">查看微博</a></p></div>

     <a href="javascript:window.opener=null;window.close();">直接关闭本页面</a>
  </body>
Eof;
        }
    }
예제 #9
0
<?php

require '../../../common.inc.php';
require 'init.inc.php';
$OAUTH[$site]['sync'] or exit;
$_token = get_cookie('sina_token');
if ($_token) {
    require '../post.inc.php';
    $o = new SaeTClientV2(WB_AKEY, WB_SKEY, $_token);
    $rec = $thumb ? $o->upload($content, $thumb) : $o->update($content);
    #log_write($rec, 'wb', 1);
    if (isset($rec['error_code']) && $rec['error_code'] > 0) {
        //fail
    } else {
        //success
    }
}
예제 #10
0
include_once 'saetv2.ex.class.php';
ignore_user_abort(true);
do {
    $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
    $ms = $c->home_timeline(1, 50, 0, 0, 0, 0);
    $id = 0;
    $id = file_get_contents("id.log");
    echo $id;
    for ($i = 0; $i < count($ms['statuses']); $i++) {
        if (!empty($ms['statuses'][$i]['retweeted_status'])) {
            if ($ms['statuses'][$i]['retweeted_status']['reposts_count'] > 80 || $ms['statuses'][$i]['retweeted_status']['comments_count'] > 80) {
            }
            if ($ms['statuses'][$i]['retweeted_status']['id'] > $id) {
                if (!empty($ms['statuses'][$i]['retweeted_status']['original_pic'])) {
                    if (strpos($ms['statuses'][$i]['retweeted_status']['text'], "http") > 0) {
                        $c->upload(str_replace("http", "(via " . $ms['statuses'][$i]['retweeted_status']['user']['name'] . ") http", $ms['statuses'][$i]['retweeted_status']['text']), $ms['statuses'][$i]['retweeted_status']['original_pic'], null, null);
                    } else {
                        $c->upload($ms['statuses'][$i]['retweeted_status']['text'] . "(via " . $ms['statuses'][$i]['retweeted_status']['user']['name'] . ")", $ms['statuses'][$i]['retweeted_status']['original_pic'], null, null);
                    }
                } else {
                    if (strpos($ms['statuses'][$i]['retweeted_status']['text'], "http") > 0) {
                        $c->update(str_replace("http", "(via " . $ms['statuses'][$i]['retweeted_status']['user']['name'] . ") http", $ms['statuses'][$i]['retweeted_status']['text']));
                    } else {
                        $c->update($ms['statuses'][$i]['retweeted_status']['text'] . "(via " . $ms['statuses'][$i]['retweeted_status']['user']['name'] . ")");
                    }
                }
            }
            continue;
        }
        if ($ms['statuses'][$i]['comments_count'] > 80 || $ms['statuses'][$i]['reposts_count'] > 80) {
            if ($ms['statuses'][$i]['id'] > $id) {
예제 #11
0
파일: bind.php 프로젝트: momoim/momo-api
 public function weibo_share($share_info, $appid = 0)
 {
     //@todo 91来电秀分离
     if ($appid != 29) {
         $appid = 0;
     }
     $token_info = $this->oauth2_check($this->uid, 'weibo', $appid);
     if (!$token_info) {
         return array('code' => 401);
     }
     if ($token_info['updated'] + $token_info['expires_in'] < time()) {
         return array('code' => 403);
     }
     require_once Kohana::find_file('vendor', 'weibo/saetv2.ex.class');
     $site_setting = $this->weibo_settings($appid);
     $c = new SaeTClientV2($site_setting['key'], $site_setting['secret'], $token_info['access_token']);
     //$c->set_debug(true);
     $status = $share_info['text'];
     if ($share_info['video']) {
         $r = $c->upload($status, $share_info['video']['url'] . '?filetype=gif');
     } elseif ($share_info['images']) {
         $r = $c->upload($status, $share_info['images'][0]);
     } else {
         $r = $c->update($status);
     }
     if ($r['id']) {
         return array('code' => 200);
     } elseif (in_array(intval($r['error_code']), array(21315, 21327, 21319))) {
         return array('code' => 403);
     } else {
         return array('code' => 400, 'data' => $r);
     }
 }
예제 #12
0
 function send_action()
 {
     if (@$_SESSION['islogined'] <= 0 || empty($_SESSION['share_id'])) {
         exit('非法访问!');
     }
     $token = ck::get('token');
     $c = new SaeTClientV2(Sconfig::$weibo['APPKEY'], Sconfig::$weibo['APPSECRET'], $token['access_token']);
     $content = @$_POST['textarea'];
     $follow360 = @$_POST['follow360'];
     echo json_encode(array('status' => 'success'));
     fastcgi_finish_request();
     if ($follow360 == 'on') {
         //TODO: 调用关注极速360官方微博
         $r = $c->follow_by_id('1808070557');
     }
     $shareContent = strip_tags(trim($content));
     $ext_info = gClass('ExtStorage')->find_one($_SESSION['share_id']);
     $detailpicArr = json_decode($ext_info['descpic'], true);
     $ext_info['detailpic'] = $detailpicArr[0];
     $r = $c->upload($shareContent, $ext_info['detailpic']);
     $r = $c->follow_by_id('1230315942');
 }
예제 #13
0
 /**
  *发微薄函数对图片,视频,文字判断。
  */
 function send_weibo()
 {
     $ret = array();
     if (isset($_REQUEST['text'])) {
         $str_send = $_REQUEST['text'];
     } else {
         $str_send = '';
     }
     $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['weibo_token']['access_token']);
     if ($_REQUEST['video']) {
         $str_send .= $_REQUEST['video'];
         //加入视频
         // echo '加入视频 :'.$str_send;
     }
     if ($_REQUEST['pic']) {
         $ret = $c->upload($str_send, $_REQUEST['pic']);
         //发送微博,图片
         // echo '发送微博,图片 :'.$str_send.$_REQUEST['pic'];
     } else {
         $ret = $c->update($str_send);
         //发送微博
         // echo '发送微博 :';
     }
     if (isset($ret['error_code']) && $ret['error_code'] > 0) {
         echo "<p>发送失败,错误:{$ret['error_code']}:{$ret['error']}</p>";
     } else {
         return $ret;
     }
 }
예제 #14
0
 public function sentShare($uid, $data)
 {
     global $_FANWE;
     static $client = NULL;
     if ($client === NULL) {
         $uid = (int) $uid;
         $bind = FS("User")->getUserBindByType($uid, 'sina');
         $client = new SaeTClientV2($this->config['app_key'], $this->config['app_secret'], $bind['access_token']);
     }
     try {
         $data['content'] .= ' ' . $data['url'];
         if (empty($data['img'])) {
             $msg = $client->update($data['content']);
         } else {
             $msg = $client->upload($data['content'], $data['img']);
         }
         //print_r($msg);
         return true;
     } catch (Exception $e) {
         //print_r($e);
     }
     return false;
 }
예제 #15
0
/**
 * 发送新浪微博
 */
function sendSinaWeibo($row, $P)
{
    // 如果没有得到本类微博的授权,不发表
    if (!$P['sinalastkey'] || !$P['sinakey']) {
        return false;
    }
    $option = $P['typeoption']['sina'];
    if (!$option) {
        return false;
    }
    // 准备微博文字和图片
    getWeiboText($row, $option, $weibocontent);
    $sinaappkey = $P['sinakey']['oauth_token'];
    $sinasecret = $P['sinakey']['oauth_token_secret'];
    try {
        $c = new SaeTClientV2($sinaappkey, $sinasecret, $P['sinalastkey']['oauth_token_secret']);
        // 如果有图片,上传图片,发表有图片的微博
        if ($weibocontent['imgurl']) {
            $rtninfo = $c->upload($weibocontent['text'], $weibocontent['imgurl']);
        } else {
            // 发表没有图片的微博
            $rtninfo = $c->update($weibocontent['text']);
        }
    } catch (Exception $e) {
        return false;
    }
    if ($rtninfo['error_code']) {
        return false;
    }
    return "type=sina:id={$rtninfo['id']}";
}
예제 #16
0
<?php

/**************************************************
	#  微博图床 V1 &copy;  lolimilk.com
	#  upsina.php  Created on 2013.08.06
	#	 Weibo: http://weibo.com/614520789
***************************************************/
header('Content-Type:text/html;charset=utf-8');
session_start();
include_once 'config.php';
include_once 'saetv2.ex.class.php';
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
if (isset($_FILES['Filedata1']['tmp_name'])) {
    $weekarray = array("日", "一", "二", "三", "四", "五", "六");
    $msg1 = $c->upload("#SinaUploader#" . date("Y-m-d H:i:s") . "星期" . $weekarray[date("w")], $_FILES['Filedata1']['tmp_name']);
    $msg2 = $c->user_timeline_by_id($_SESSION['userinfo']['id'], 1, 1, 0, 0, 0, 1, 0);
    ?>


<?php 
    echo '<input type="text" readonly="readonly" onmouseover="this.select()" onfocus="this.select()" value="[img]' . $msg2['statuses']['0']['original_pic'] . '[/img]" style="width:340px;">';
    echo '<button class="thumbnail">预览<span><img src="' . $msg2['statuses']['0']['bmiddle_pic'] . '" width="50" border="0"></span>';
    echo "<br>";
    ?>

<?php 
}
예제 #17
0
 public function actionPost()
 {
     if ($this->isPost()) {
         if (Yii::app()->session['is_login']) {
             $request = Yii::app()->getRequest();
             $photoUpload = CUploadedFile::getInstanceByName("photo");
             $description = $request->getPost('description');
             if ($photoUpload) {
                 $mime = $photoUpload->getType();
                 $allowMime = array("image/gif", "image/png", "image/jpeg", "image/jpg");
                 if (!in_array($mime, $allowMime)) {
                     return $this->responseError("photo's media type is not allowed");
                 } else {
                     $dir = ROOT_PATH . "/upload/tmp/";
                     if (!is_dir($dir)) {
                         mkdir($dir, 0777, TRUE);
                     }
                     $filename = uniqid() . '_' . time() . '.' . $photoUpload->extensionName;
                     $to = $dir . "/" . $filename;
                     $ret = $photoUpload->saveAs($to);
                     if ($ret) {
                         $c = new SaeTClientV2(WB_AKEY, WB_SKEY, Yii::app()->session['weibo_access_token']);
                         //TODO: Change the image url
                         $contents = $c->upload($description, 'http://ww4.sinaimg.cn/mw690/59209e01gw1ed6hevjpp9j20g60qo0vg.jpg');
                         if (isset($contents['error_code'])) {
                             $this->responseError($contents);
                         }
                         unlink($to);
                     }
                 }
             } else {
                 return $this->responseError("not get photo");
             }
         } else {
             return $this->responseError("not login");
         }
     } else {
         return $this->responseError("not post");
     }
 }
예제 #18
0
 public function share($text, $image, $pid)
 {
     $month = intval($month);
     $text = str_replace('http://www.uggaustralia.cn/thisisugg', "http://www.uggaustralia.cn/thisisugg?fromWeiboShare=1&toID=" . $pid, $text);
     //$text .= "";
     //$realPath = dirname(__FILE__);	//$realPath = str_replace('application2/model','',$realPath);
     //$image = preg_replace('/^http:\/\/ugg\.innomative-staging.com\/(mobile\/)?/gi',"",$image);
     //$image = 'http://ugg.innomative-staging.com/mobile/'.$image;
     $c = new SaeTClientV2(WB_AKEY, WB_SKEY, getWeiboToken());
     $ret = $c->upload($text, MY_DOMAIN . $image);
     //发送微博
     if (isset($ret['error_code']) && $ret['error_code'] > 0) {
         $data['success'] = false;
         $data['error_code'] = '103';
         $data['message'] = "<p>发送失败,错误:{$ret['error_code']}:{$ret['error']}</p>";
     } else {
         $data['success'] = true;
         $data['message'] = $this->weiboID;
         $this->weiboID = $ret['id'];
         $data['data'] = $checkResult['data'];
     }
     $this->loadData(getWeiboToken());
     $statement = "INSERT INTO `ugg_weibo_share` (`weibo_userid`,`share_text`,`share_img`,`time`) VALUES ('" . ms($this->getUserID()) . "','" . ms($text) . "','" . ms($imageShare) . "','" . time() . "')";
     DB::query($statement);
     //$statement = "INSERT INTO `ugg_vote` (`uid`,`pid`,`create_time`) VALUES ('".ms($this->getUserID())."','".ms($pid)."','".time()."')";
     //DB::query($statement);
     //$lastID = DB::getLastID();
     //DB::query("INSERT INTO `vans_lb_share` (`month`, `photo`, `weibo_share_id`, `time`) VALUES ($month, ".intval($image).", $lastID, ".time().")");
     return $data;
 }
예제 #19
0
파일: Sina_api.php 프로젝트: macall/jsd
 public function send_message($data)
 {
     static $client = NULL;
     if ($client === NULL) {
         require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php';
         $uid = intval($GLOBALS['user_info']['id']);
         $udata = $GLOBALS['db']->getRow("select sina_token from " . DB_PREFIX . "user where id = " . $uid);
         $client = new SaeTClientV2($this->api['config']['app_key'], $this->api['config']['app_secret'], $udata['sina_token']);
     }
     try {
         if (empty($data['img'])) {
             $msg = $client->update($data['content']);
         } else {
             $msg = $client->upload($data['content'], $data['img']);
         }
         if ($msg['error']) {
             $result['status'] = false;
             $result['msg'] = "新浪微博同步失败,请偿试重新通过腾讯微博登录或得新授权。";
         } else {
             $result['status'] = true;
             $result['msg'] = "success";
         }
     } catch (Exception $e) {
     }
     return $result;
 }
예제 #20
0
    {
        $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['sina']['token']['access_token']);
        return $c->update($status);
    }
    /**
	 * 发表图片微博