コード例 #1
0
ファイル: p_sync.php プロジェクト: lyhiving/mini_class
 case 'tqq':
     if (isset($_GET['lt']) && $_GET['lt'] == 1) {
         $d_db = sprintf('delete from %s where aid=%s and name=%s', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text'));
         $result = mysql_query($d_db) or die('');
         header('Location:./?m=profile&t=sync&n=' . $nct);
         exit;
     }
     require_once 'lib/tqq.php';
     $is_sync = 0;
     $s_dby = sprintf('select id, s_id, s_t, s_r, s_n, edate, is_show from %s where aid=%s and name=%s limit 1', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text'));
     $q_dby = mysql_query($s_dby) or die('');
     $r_dby = mysql_fetch_assoc($q_dby);
     if (mysql_num_rows($q_dby) > 0) {
         if ($r_dby['edate'] < time() && $r_dby['edate'] > 0 && $r_dby['s_r'] != '') {
             $o = new tqqPHP($config['tqq_key'], $config['tqq_se']);
             $result = $o->access_token_refresh($r_dby['s_r']);
             if (isset($result['access_token']) && $result['access_token'] != '') {
                 $r_dby['s_t'] = $result['access_token'];
                 $r_dby['s_r'] = $result['refresh_token'];
                 $r_dby['edate'] = time() + $result['expires_in'];
             }
             $u_db = sprintf('update %s set s_t=%s, s_r=%s, edate=%s, mdate=%s where id=%s', $dbprefix . 'm_sync', SQLString($r_dby['s_t'], 'text'), SQLString($r_dby['s_r'], 'text'), SQLString($r_dby['edate'], 'int'), time(), $r_dby['id']);
             $result = mysql_query($u_db) or die('');
         }
         $o = new tqqPHP($config['tqq_key'], $config['tqq_se'], $r_dby['s_t'], $r_dby['s_id']);
         $ma = $o->me();
         if (isset($ma['ret']) && $ma['ret'] == 0 && isset($ma['data']) && is_array($ma['data'])) {
             $is_sync = 1;
             $d_db = sprintf('delete from %s where aid<>%s and name=%s and s_id=%s', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text'), SQLString($ma['data']['openid'], 'text'));
             $result = mysql_query($d_db) or die('');
             $me_url = 'http://t.qq.com/' . $ma['data']['name'];