Exemplo n.º 1
0
if (TOQQ == 0) {
    $sina_tweets = $sina_c->user_timeline(1, 1);
    if (!empty($sina_tweets['error_code'])) {
        exit;
    } else {
        $isSinaTrue = true;
        switch ($isSinaTrue) {
            case strtotime($sina_tweets[0]['created_at']) <= $sina_last_update:
                $isSinaTrue = false;
                break;
            case !empty($sina_tweets[0]['retweeted_status']):
                //判断是否转发、评论、对话
                $isSinaTrue = false;
                break;
            case preg_match('/^-/', trim($sina_tweets[0]['text'])):
                // 以 "-" 开关的微博不同步
                $isSinaTrue = false;
                break;
        }
        if ($isSinaTrue) {
            //同步操作
            try {
                $ret = $qq_c->postOne('- ' . $sina_tweets[0]['text'], $sina_tweets[0]['original_pic'], $sina_tweets[0]['geo']['coordinates'][1], $sina_tweets[0]['geo']['coordinates'][0]);
                if ($ret['ret'] == 0) {
                    memcache_set($mmc, "sina_last_update", strtotime($sina_tweets[0]['created_at']));
                }
            } catch (Exception $e) {
            }
        }
    }
}
Exemplo n.º 2
0
 function sendtalk()
 {
     $weibo = D('Weibobind');
     $ctent = D('Content');
     $user = Action::$login_user;
     $contentid = mysql_insert_id();
     if ($contentid) {
         $content = $ctent->where("content_id='{$contentid}'")->find();
         $text = $content['content_body'];
         $media = $content['media_body'];
         $text = str_replace('&amp;', '&', $text);
         $text = ubbreplace($text);
         $media = ubbreplace($content['media_body']);
         $st = getsubstr($media, 0, 7, false);
         if ($st == 'http://' || $st == '/photo/') {
             if ($st == '/photo/') {
                 $media = __PUBLIC__ . '/attachments' . $media;
                 $media = str_replace('s_', '', $media);
             }
             $text = $text . $media;
         }
         $text = clean_html($text);
     }
     if ($text) {
         $bind = $weibo->where("uid='{$user['user_id']}'")->find();
         if ($bind['sina_uid'] && $bind['sina_token'] && $bind['sina_tsecret'] && $bind['sendtosina'] == 1) {
             $sinawb = new WeiboClient(WB_AKEY, WB_SKEY, $bind['sina_token'], $bind['sina_tsecret']);
             $me = $sinawb->verify_credentials();
             if ($me['id'] == $bind['sina_uid']) {
                 $rssina = $sinawb->update($text);
             }
         }
         if ($bind['qq_uid'] && $bind['qq_token'] && $bind['qq_tsecret'] && $bind['sendtoqq'] == 1) {
             include_once "qqweibo/api_client.php";
             $qqwb = new MBApiClient(MB_AKEY, MB_SKEY, $bind['qq_token'], $bind['qq_tsecret']);
             $me = $qqwb->getUserInfo();
             if ($me['data']['name'] == $bind['qq_uid']) {
                 $p = array('c' => $text, 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
                 $rsqq = $qqwb->postOne($p);
             }
         }
     }
 }
Exemplo n.º 3
0
 public function send_message($data)
 {
     static $client = NULL;
     if ($client === NULL) {
         define("MB_RETURN_FORMAT", 'json');
         define("MB_API_HOST", 'open.t.qq.com');
         require_once APP_ROOT_PATH . 'system/api_login/Tencent/api_client.php';
         $uid = intval($GLOBALS['user_info']['id']);
         $udata = $GLOBALS['db']->getRow("select tencent_app_key,tencent_app_secret from " . DB_PREFIX . "user where id = " . $uid);
         $client = new MBApiClient($this->api['config']['app_key'], $this->api['config']['app_secret'], $udata['tencent_app_key'], $udata['tencent_app_secret']);
     }
     $p['c'] = $data['content'];
     //组装autho类所需的图片参数内容
     if (!empty($data['img'])) {
         $filename = $data['img'];
         $pic[0] = $this->get_image_mime($filename);
         $pic[1] = reset(explode('?', basename($filename)));
         $pic[2] = file_get_contents($filename);
         $p['p'] = $pic;
     }
     $p['ip'] = get_client_ip();
     $p['type'] = 1;
     try {
         $msg = $client->postOne($p);
         //			echo "success";
         //			print_r($msg);
     } catch (Exception $e) {
         //			echo "error";
         //			print_r($e);
     }
 }
Exemplo n.º 4
0
/**
 * 发送腾讯微博
 */
function sendTencentWeibo($weibocontent, $P)
{
    // 如果没有腾讯的授权,直接返回
    if (!$P['tencentlastkey']) {
        return;
    }
    // 准备微博对象
    $c = new MBApiClient(MB_AKEY, MB_SKEY, $P['tencentlastkey']['oauth_token'], $P['tencentlastkey']['oauth_token_secret']);
    // 如果有图片,上传图片,发表有图片的微博
    if ($weibocontent['imgfile']) {
        $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'p' => array(null, 'pic from joomla', $weibocontent['imgfile']), 'type' => 0);
    } else {
        // 发表没有图片的微博
        $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
    }
    $rtn = $c->postOne($p);
}
Exemplo n.º 5
0
 $user = sql_query('SELECT * FROM ' . DB_PREFIX . 'user WHERE username = "******"');
 $user = mysql_fetch_array($user);
 $microblog = unserialize($user['microblog']);
 if (is_array($mblog)) {
     foreach ($mblog as $key => $var) {
         if ($var == 'fanfou') {
             sync_fanfou(strip_tags($entry), $microblog['ff']['name'], $microblog['ff']['pass']);
         } elseif ($var == 'sina') {
             $c = new WeiboClient(WB_AKEY, WB_SKEY, $microblog['sina']['oauth_token'], $microblog['sina']['oauth_token_secret']);
             $c->update($entry);
         } elseif ($var == 'digu') {
             sync_digu(strip_tags($entry), $microblog['dg']['name'], $microblog['dg']['pass']);
         } elseif ($var == 'qq') {
             $tecent = new MBApiClient(MB_AKEY, MB_SKEY, $microblog['qq']['oauth_token'], $microblog['qq']['oauth_token_secret']);
             $p = array('c' => $entry, 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
             $tecent->postOne($p);
         } elseif ($var == '163') {
             $wangyi = new wy_WeiboClient(WY_AKEY, WY_SKEY, $microblog['163']['oauth_token'], $microblog['163']['oauth_token_secret']);
             $wangyi->update($entry);
         } elseif ($var == 'sohu') {
             sync_sohu($entry, $microblog['sh']['name'], $microblog['sh']['pass']);
         } elseif ($var == 'tumblr') {
             sync_tumblr($entry, $microblog['tumblr']['name'], $microblog['tumblr']['pass']);
         } elseif ($var == 'leihou') {
             sync_leihou($entry, $microblog['lh']['name'], $microblog['lh']['pass']);
         }
     }
 }
 if ($_GET['type'] == 'm') {
     go('/m/index.php');
 } else {
Exemplo n.º 6
0
/**
 * 发送腾讯微博
 */
function sendTencentWeibo($row, $P)
{
    // 如果没有得到本类微博的授权,不发表
    if (!$P['tencentlastkey']) {
        return false;
    }
    $option = $P['typeoption']['tencent'];
    if (!$option) {
        return false;
    }
    // 准备微博文字和图片
    getWeiboText($row, $option, $weibocontent);
    // 准备微博对象
    try {
        $c = new MBApiClient(MB_AKEY, MB_SKEY, $P['tencentlastkey']['oauth_token'], $P['tencentlastkey']['oauth_token_secret']);
        // 如果有图片,上传图片,发表有图片的微博
        if ($weibocontent['imgfile']) {
            $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'p' => array(null, 'pic from joomla', $weibocontent['imgfile']), 'type' => 0);
        } else {
            // 发表没有图片的微博
            $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
        }
        $rtninfo = $c->postOne($p);
    } catch (Exception $e) {
        return false;
    }
    if ($rtninfo['error_code']) {
        return false;
    }
    return "type=tencent:id={$rtninfo['data']['id']}";
}
Exemplo n.º 7
0
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);
        }
    }
}
Exemplo n.º 8
0
<?php

@header('Content-Type:text/html;charset=utf-8');
session_start();
@(require_once 'config.php');
@(require_once 'oauth.php');
@(require_once 'opent.php');
@(require_once 'api_client.php');
if (isset($_POST['content'])) {
    $c = new MBApiClient(MB_AKEY, MB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
    //发消息
    //	*@content: 微博内容
    $p = array('c' => $_POST['content'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'p' => array($_FILES['pic']['type'], $_FILES['pic']['name'], file_get_contents($_FILES['pic']['tmp_name'])), 'type' => 0);
    print_r($c->postOne($p));
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  内容:<input type="text" name="content" id="content" />
  图片:<input type="file" name="pic" id="pic" />
  <input type="submit" name="button" id="button" value="提交" />
</form>