本文整理汇总了PHP中SaeTClientV2::upload方法的典型用法代码示例。如果您正苦于以下问题:PHP SaeTClientV2::upload方法的具体用法?PHP SaeTClientV2::upload怎么用?PHP SaeTClientV2::upload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SaeTClientV2
的用法示例。
在下文中一共展示了SaeTClientV2::upload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* 推送信息
*/
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: sina
/**
* 新浪微博分享
*/
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: addSinaWeiboUpload
/**
* 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: _execute_sinashare
/**
* 新浪微博分享
*
* @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: Sina
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: _sync_weibo
/**
*
* @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: yjl_uwb
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: sendwb
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>
//.........这里部分代码省略.........
示例9:
<?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:
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: weibo_share
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: exit
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: array
/**
*发微薄函数对图片,视频,文字判断。
*/
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: sentShare
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: sendSinaWeibo
/**
* 发送新浪微博
*/
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']}";
}