public function get_tx_open_id($platdata, $access_token) { //根据uid,name,access_token获取用户头像,名称 $c = new ClientV2($platdata['akey'], $platdata['skey'], $platdata['response_type'], $access_token['access_token']); $userdata = $c->get_tx_open_id($this->settings['share_plat'][$platdata['type']]['openidurl']); return $userdata; }
public function txweibo_create($checktoken, $uid, $name) { if ($checktoken) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); if ($this->settings['share_plat'][$checktoken['data']['type']]['friendships_create']) { $url = $this->settings['share_plat'][$checktoken['data']['type']]['friendships_create']; } else { $url = 'https://open.t.qq.com/api/friends/add'; } $result = $c->txfollow_by_id($url, $uid, $name, $checktoken['data']['access_token']['openid']); $ret = array(); if (!empty($result['openid'])) { $ret = array('id' => $result['openid'], 'screen_name' => $result['name'], 'name' => $result['name']); } else { $ret['error'] = empty($result['error']) ? "empty" : $result['error']; } return $ret; } else { return "NO_TOKEN_DATA"; } }
public function other_get_mention($checktoken, $since_id, $page, $count) { if ($checktoken) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $result = $c->get_user_mention($checktoken['data']['platdata']['user_mentionurl'], $since_id, $page, $count, '', true); // print_r($result);exit; $ret = array(); if (!empty($result['statuses'])) { foreach ($result['statuses'] as $k => $v) { $ret[$k]['id'] = empty($v['id']) ? '' : $v['id']; $ret[$k]['text'] = empty($v['text']) ? '' : $v['text']; $ret[$k]['screen_name'] = empty($v['user']['screen_name']) ? '' : $v['user']['screen_name']; $ret[$k]['name'] = empty($v['user']['name']) ? '' : $v['user']['name']; $ret[$k]['avatar'] = empty($v['user']['avatar_large']) ? '' : $v['user']['avatar_large']; $ret[$k]['created_at'] = empty($v['created_at']) ? '' : strtotime($v['created_at']); $ret[$k]['original_pic'] = empty($v['original_pic']) ? '' : $v['original_pic']; $ret[$k]['from'] = empty($v['source']) ? '' : $v['source']; $ret[$k]['reposts_count'] = empty($v['reposts_count']) ? 0 : $v['reposts_count']; $ret[$k]['comments_count'] = empty($v['comments_count']) ? 0 : $v['comments_count']; $ret[$k]['from'] = empty($v['source']) ? '' : $v['source']; $ret[$k]['picsize'] = array('thumbnail' => 'thumbnail', 'bmiddle' => 'bmiddle', 'large' => 'large'); $ret[$k]['geo'] = empty($v['geo']) ? array() : $v['geo']; if (!empty($v['retweeted_status'])) { $ret[$k]['retweeted_status']['id'] = empty($v['retweeted_status']['id']) ? '' : $v['retweeted_status']['id']; $ret[$k]['retweeted_status']['created_at'] = empty($v['retweeted_status']['created_at']) ? '' : strtotime($v['retweeted_status']['created_at']); $ret[$k]['retweeted_status']['text'] = empty($v['retweeted_status']['text']) ? '' : $v['retweeted_status']['text']; $ret[$k]['retweeted_status']['original_pic'] = empty($v['retweeted_status']['original_pic']) ? '' : $v['retweeted_status']['original_pic']; $ret[$k]['retweeted_status']['screen_name'] = empty($v['retweeted_status']['user']['screen_name']) ? '' : $v['retweeted_status']['user']['screen_name']; $ret[$k]['retweeted_status']['avatar'] = empty($v['retweeted_status']['user']['avatar_large']) ? '' : $v['retweeted_status']['user']['avatar_large']; $ret[$k]['retweeted_status']['name'] = empty($v['retweeted_status']['user']['name']) ? '' : $v['retweeted_status']['user']['name']; $ret[$k]['retweeted_status']['reposts_count'] = empty($v['retweeted_status']['reposts_count']) ? 0 : $v['retweeted_status']['reposts_count']; $ret[$k]['retweeted_status']['comments_count'] = empty($v['retweeted_status']['comments_count']) ? 0 : $v['retweeted_status']['comments_count']; } } } else { $ret['error'] = empty($result['error']) ? "empty" : $result['error']; } // print_r($ret);exit; return $ret; } else { return "NO_TOKEN_DATA"; } }
public function other_revoke($checktoken) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $result = $c->revoke_by_access_token($checktoken['data']['platdata']['revoke_authurl']); if (empty($result['created_at'])) { $ret['error'] = empty($result['error']) ? 'empty' : $result['error']; } else { $ret['msg'] = 'ok'; } // print_r($result); return $ret; }
public function other_favorite($checktoken, $weibo_id) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $result = $c->favorite($checktoken['data']['platdata']['favorite_addurl'], $weibo_id, '', true); if (empty($result['created_at'])) { $ret['error'] = empty($result['error']) ? 'empty' : $result['error']; } else { $ret['msg'] = 'ok'; } return $ret; }
public function other_get_comments($checktoken, $weibo_id, $since_id = '', $since_time = '', $page = '', $count = '') { if ($checktoken) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $result = $c->get_comments($checktoken['data']['platdata']['comment_showurl'], $weibo_id, $since_id, $since_time, $page, $count, '', true); // print_r($result);exit; $ret = array(); if (empty($result['error']) && $result['comments']) { foreach ($result['comments'] as $k => $v) { $ret[$k]['id'] = $v['id']; $ret[$k]['mid'] = $v['mid']; $ret[$k]['created_at'] = empty($v['created_at']) ? '' : strtotime($v['created_at']); $ret[$k]['text'] = empty($v['text']) ? '' : $v['text']; if (!empty($v['user'])) { $ret[$k]['user']['id'] = empty($v['user']['id']) ? '' : $v['user']['id']; $ret[$k]['user']['screen_name'] = empty($v['user']['screen_name']) ? '' : $v['user']['screen_name']; $ret[$k]['user']['name'] = empty($v['user']['name']) ? '' : $v['user']['name']; $ret[$k]['user']['location'] = empty($v['user']['location']) ? '' : $v['user']['location']; $ret[$k]['user']['avatar'] = empty($v['user']['avatar_large']) ? '' : $v['user']['avatar_large']; $ret[$k]['user']['followers_count'] = empty($v['user']['followers_count']) ? '' : $v['user']['followers_count']; $ret[$k]['user']['friends_count'] = empty($v['user']['friends_count']) ? '' : $v['user']['friends_count']; $ret[$k]['user']['statuses_count'] = empty($v['user']['statuses_count']) ? '' : $v['user']['statuses_count']; } if (!empty($v['status'])) { $ret[$k]['status']['id'] = empty($v['status']['id']) ? '' : $v['status']['id']; $ret[$k]['status']['mid'] = empty($v['status']['mid']) ? '' : $v['status']['mid']; $ret[$k]['status']['text'] = empty($v['status']['text']) ? '' : $v['status']['text']; if (!empty($v['status']['user'])) { $ret[$k]['status']['user']['id'] = empty($v['status']['user']['id']) ? '' : $v['status']['user']['id']; $ret[$k]['status']['user']['screen_name'] = empty($v['status']['user']['screen_name']) ? '' : $v['status']['user']['screen_name']; $ret[$k]['status']['user']['name'] = empty($v['status']['user']['name']) ? '' : $v['status']['user']['name']; $ret[$k]['status']['user']['location'] = empty($v['status']['user']['location']) ? '' : $v['status']['user']['location']; $ret[$k]['status']['user']['description'] = empty($v['status']['user']['description']) ? '' : $v['status']['user']['description']; $ret[$k]['status']['user']['avatar'] = empty($v['status']['user']['avatar_large']) ? '' : $v['status']['user']['avatar_large']; $ret[$k]['status']['user']['followers_count'] = empty($v['status']['user']['followers_count']) ? '' : $v['status']['user']['followers_count']; $ret[$k]['status']['user']['friends_count'] = empty($v['status']['user']['friends_count']) ? '' : $v['status']['user']['friends_count']; $ret[$k]['status']['user']['statuses_count'] = empty($v['status']['user']['statuses_count']) ? '' : $v['status']['user']['statuses_count']; } $ret[$k]['status']['reposts_count'] = empty($v['status']['reposts_count']) ? 0 : $v['status']['reposts_count']; $ret[$k]['status']['comments_count'] = empty($v['status']['comments_count']) ? 0 : $v['status']['comments_count']; $ret[$k]['status']['attitudes_count'] = empty($v['status']['attitudes_count']) ? 0 : $v['status']['attitudes_count']; $ret[$k]['status']['created_at'] = empty($v['status']['created_at']) ? '' : strtotime($v['status']['created_at']); } } } else { $ret['error'] = empty($result['error']) ? 'emtpy' : $result['error']; } // print_r($ret);exit; return $ret; } else { return "NO_TOKEN_DATA"; } }
public function other_get_detail($checktoken, $weibo_id) { if ($checktoken) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $v = $c->detail_show($checktoken['data']['platdata']['detailurl'], $weibo_id, '', true); // print_r($v);exit; $ret = array(); if (empty($v['error'])) { $ret['id'] = empty($v['id']) ? '' : $v['id']; $ret['text'] = empty($v['text']) ? '' : $v['text']; $ret['screen_name'] = empty($v['user']['screen_name']) ? '' : $v['user']['screen_name']; $ret['name'] = empty($v['user']['name']) ? '' : $v['user']['name']; $ret['avatar'] = empty($v['user']['avatar_large']) ? '' : $v['user']['avatar_large']; $ret['created_at'] = empty($v['created_at']) ? '' : strtotime($v['created_at']); $ret['original_pic'] = empty($v['original_pic']) ? '' : $v['original_pic']; $ret['from'] = empty($v['source']) ? '' : $v['source']; $ret['reposts_count'] = empty($v['reposts_count']) ? 0 : $v['reposts_count']; $ret['comments_count'] = empty($v['comments_count']) ? 0 : $v['comments_count']; $ret['from'] = empty($v['source']) ? '' : $v['source']; $ret['picsize'] = array('thumbnail' => 'thumbnail', 'bmiddle' => 'bmiddle', 'large' => 'large'); if (!empty($v['retweeted_status'])) { $ret['retweeted_status']['id'] = empty($v['retweeted_status']['id']) ? '' : $v['retweeted_status']['id']; $ret['retweeted_status']['created_at'] = empty($v['retweeted_status']['created_at']) ? '' : strtotime($v['retweeted_status']['created_at']); $ret['retweeted_status']['text'] = empty($v['retweeted_status']['text']) ? '' : $v['retweeted_status']['text']; $ret['retweeted_status']['original_pic'] = empty($v['retweeted_status']['original_pic']) ? '' : $v['retweeted_status']['original_pic']; $ret['retweeted_status']['screen_name'] = empty($v['retweeted_status']['user']['screen_name']) ? '' : $v['retweeted_status']['user']['screen_name']; $ret['retweeted_status']['avatar'] = empty($v['retweeted_status']['user']['avatar_large']) ? '' : $v['retweeted_status']['user']['avatar_large']; $ret['retweeted_status']['name'] = empty($v['retweeted_status']['user']['name']) ? '' : $v['retweeted_status']['user']['name']; $ret['retweeted_status']['reposts_count'] = empty($v['retweeted_status']['reposts_count']) ? 0 : $v['retweeted_status']['reposts_count']; $ret['retweeted_status']['comments_count'] = empty($v['retweeted_status']['comments_count']) ? 0 : $v['retweeted_status']['comments_count']; } } else { $ret['error'] = empty($v['error']) ? 'empty' : $v['error']; } // print_r($ret);exit; return $ret; } else { return "NO_TOKEN_DATA"; } }
public function other_toshare($tokendata, $platdata) { if ($tokendata) { $text = $this->input['text']; $picpath = urldecode($this->input['picpath']); $lat = $this->input['lat']; $long = $this->input['long']; if ($text) { if ($picpath) { $file = create_image_dir($picpath, CUR_CONF_PATH . $this->settings['image_cache']); $new_picpath = $file['filepath'] . $file['filename']; $new_picpath = upload_image($picpath, $file); } $access_token = $tokendata['access_token']; $c = new ClientV2($tokendata['akey'], $tokendata['skey'], $tokendata['response_type'], $access_token['access_token']); if ($picpath) { if (substr($picpath, 0, 7) == 'http://') { if (false) { $result = $c->upload($platdata['platdata']['sharepicurl'], $text, $picpath, true, $lat, $long); } else { $result = $c->upload($platdata['platdata']['sharepicurl'], $text, $new_picpath, true, $lat, $long); } } } else { $result = $c->update($platdata['platdata']['shareurl'], $text, true, $lat, $long); } $userdata = $this->get_user->show_user($platdata, $access_token, $access_token['uid']); if (!empty($result['created_at'])) { $data = array('type' => 1, 'uid' => $access_token['uid'], 'name' => $userdata['name'], 'platid' => $platdata['id'], 'url' => $tokendata['shareurl'], 'content' => $text, 'picpath' => $picpath, 'jing' => $lat, 'wei' => $long, 'addtime' => TIMENOW); $insert_id = $this->obj->insert_record($data); $return['id'] = $insert_id; $return['name'] = $userdata['name']; $return['picpath'] = $picpath; $return['addtime'] = $data['addtime']; } else { $return['error'] = $result['error']; } // print_r($userdata);exit; return $return; } else { return "没有分享的内容"; } } else { return "无可用分享信息,请重新登录"; } }
public function other_follow($checktoken, $uid, $name, $del_follow) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $url = $del_follow ? $checktoken['data']['platdata']['del_followurl'] : $checktoken['data']['platdata']['followurl']; $result = $c->follow_by_id($url, $uid); if (empty($result['created_at'])) { $ret['error'] = empty($result['error']) ? 'empty' : $result['error']; } else { $ret['msg'] = 'ok'; } return $ret; }
public function other_search_user($checktoken, $keyword) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $result = $c->search_user($checktoken['data']['platdata']['search_userurl'], $keyword, '', true); $ret = array(); if (!empty($result[0]['screen_name'])) { foreach ($result as $v) { $ret[]['name'] = $v['screen_name']; } } return $ret; }
public function other_repost($checktoken, $weibo_id, $text, $is_comment) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $result = $c->repost($checktoken['data']['platdata']['reposturl'], $weibo_id, $text, $is_comment, '', true); if (empty($result['created_at'])) { $ret['error'] = empty($result['error']) ? 'empty' : $result['error']; } else { $ret['msg'] = 'ok'; } return $ret; }
public function other_getuser($checktoken, $uid, $name) { $ret = array(); $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); $result = $c->get_other_user($checktoken['data']['platdata']['other_userurl'], $uid, $name, '', true); // print_r($result);exit; if (empty($result['error'])) { $ret['uid'] = empty($result['id']) ? '' : $result['id']; $ret['screen_name'] = empty($result['screen_name']) ? '' : $result['screen_name']; $ret['name'] = empty($result['name']) ? '' : $result['name']; $ret['location'] = empty($result['location']) ? '' : $result['location']; $ret['description'] = empty($result['description']) ? '' : $result['description']; $ret['friends_count'] = empty($result['friends_count']) ? 0 : $result['friends_count']; $ret['followers_count'] = empty($result['followers_count']) ? 0 : $result['followers_count']; $ret['statuses_count'] = empty($result['statuses_count']) ? 0 : $result['statuses_count']; $ret['favourites_count'] = empty($result['favourites_count']) ? 0 : $result['favourites_count']; $ret['created_at'] = empty($result['created_at']) ? 0 : strtotime($result['created_at']); $ret['avatar'] = empty($result['avatar_large']) ? '' : $result['avatar_large']; } else { $ret['error'] = empty($result['error']) ? 'empty' : $result['error']; } return $ret; }
public function txweibo_home_timeline($checktoken, $since_id, $page, $count) { if ($checktoken) { $c = new ClientV2($checktoken['data']['akey'], $checktoken['data']['skey'], $checktoken['data']['response_type'], $checktoken['data']['access_token']['access_token']); if ($this->settings['share_plat'][$checktoken['data']['type']]['home_timelineurl']) { $url = $this->settings['share_plat'][$checktoken['data']['type']]['home_timelineurl']; } else { $url = 'https://open.t.qq.com/api/statuses/home_timeline'; } //新浪微博页码从1开始算 腾讯从0开始算 $page = $page > 0 ? $page - 1 : $page; $result = $c->get_home_timeline($url, $since_id, $page, $count, $checktoken['data']['access_token']['openid'], 'tx'); $ret = array(); if (!empty($result['data']['info'])) { foreach ($result['data']['info'] as $kk => $vv) { $ids[] = $vv['id']; } if (!in_array($since_id, $ids)) { foreach ($result['data']['info'] as $k => $v) { /* if($v['id']<=$since_id) { continue; } */ $ret[$k]['id'] = empty($v['id']) ? '' : $v['id']; $ret[$k]['from'] = empty($v['from']) ? '' : $v['from']; $ret[$k]['fromurl'] = empty($v['fromurl']) ? '' : $v['fromurl']; $ret[$k]['text'] = empty($v['text']) ? '' : $v['text']; $ret[$k]['origtext'] = empty($v['origtext']) ? '' : $v['origtext']; $ret[$k]['screen_name'] = empty($v['nick']) ? '' : $v['nick']; $ret[$k]['name'] = empty($v['name']) ? '' : $v['name']; $ret[$k]['uid'] = empty($v['openid']) ? '' : $v['openid']; $ret[$k]['video'] = empty($v['video']) ? '' : $v['video']; $ret[$k]['created_at'] = empty($v['timestamp']) ? '' : $v['timestamp']; $ret[$k]['original_pic'] = empty($v['image']) ? '' : $v['image']; $ret[$k]['avatar'] = empty($v['head']) ? '' : $v['head'] . '/180'; $ret[$k]['reposts_count'] = empty($v['count']) ? 0 : $v['count']; $ret[$k]['comments_count'] = empty($v['mcount']) ? 0 : $v['mcount']; $ret[$k]['picsize'] = array('thumbnail' => '120', 'bmiddle' => '400', 'large' => '2000'); if (!empty($v['source'])) { $ret[$k]['retweeted_status']['id'] = empty($v['source']['id']) ? '' : $v['source']['id']; $ret[$k]['retweeted_status']['text'] = empty($v['source']['text']) ? '' : $v['source']['text']; $ret[$k]['retweeted_status']['origtext'] = empty($v['source']['origtext']) ? '' : $v['source']['origtext']; $ret[$k]['retweeted_status']['video'] = empty($v['source']['video']) ? '' : $v['source']['video']; $ret[$k]['retweeted_status']['name'] = empty($v['source']['name']) ? '' : $v['source']['name']; $ret[$k]['retweeted_status']['screen_name'] = empty($v['source']['nick']) ? '' : $v['source']['nick']; $ret[$k]['retweeted_status']['created_at'] = empty($v['source']['timestamp']) ? '' : $v['source']['timestamp']; $ret[$k]['retweeted_status']['avatar'] = empty($v['source']['head']) ? '' : $v['source']['head'] . '/180'; $ret[$k]['retweeted_status']['original_pic'] = empty($v['source']['image']) ? '' : $v['source']['image']; $ret[$k]['retweeted_status']['reposts_count'] = empty($v['source']['count']) ? 0 : $v['source']['count']; $ret[$k]['retweeted_status']['comments_count'] = empty($v['source']['mcount']) ? 0 : $v['source']['mcount']; } } } else { foreach ($result['data']['info'] as $k => $v) { if ($v['id'] == $since_id) { break; } else { $ret[$k]['id'] = empty($v['id']) ? '' : $v['id']; $ret[$k]['from'] = empty($v['from']) ? '' : $v['from']; $ret[$k]['fromurl'] = empty($v['fromurl']) ? '' : $v['fromurl']; $ret[$k]['text'] = empty($v['text']) ? '' : $v['text']; $ret[$k]['origtext'] = empty($v['origtext']) ? '' : $v['origtext']; $ret[$k]['screen_name'] = empty($v['nick']) ? '' : $v['nick']; $ret[$k]['name'] = empty($v['name']) ? '' : $v['name']; $ret[$k]['uid'] = empty($v['openid']) ? '' : $v['openid']; $ret[$k]['video'] = empty($v['video']) ? '' : $v['video']; $ret[$k]['created_at'] = empty($v['timestamp']) ? '' : $v['timestamp']; $ret[$k]['original_pic'] = empty($v['image']) ? '' : $v['image']; $ret[$k]['avatar'] = empty($v['head']) ? '' : $v['head'] . '/180'; $ret[$k]['reposts_count'] = empty($v['count']) ? 0 : $v['count']; $ret[$k]['comments_count'] = empty($v['mcount']) ? 0 : $v['mcount']; $ret[$k]['picsize'] = array('thumbnail' => '120', 'bmiddle' => '400', 'large' => '2000'); if (!empty($v['source'])) { $ret[$k]['retweeted_status']['id'] = empty($v['source']['id']) ? '' : $v['source']['id']; $ret[$k]['retweeted_status']['text'] = empty($v['source']['text']) ? '' : $v['source']['text']; $ret[$k]['retweeted_status']['origtext'] = empty($v['source']['origtext']) ? '' : $v['source']['origtext']; $ret[$k]['retweeted_status']['video'] = empty($v['source']['video']) ? '' : $v['source']['video']; $ret[$k]['retweeted_status']['name'] = empty($v['source']['name']) ? '' : $v['source']['name']; $ret[$k]['retweeted_status']['screen_name'] = empty($v['source']['nick']) ? '' : $v['source']['nick']; $ret[$k]['retweeted_status']['created_at'] = empty($v['source']['timestamp']) ? '' : $v['source']['timestamp']; $ret[$k]['retweeted_status']['avatar'] = empty($v['source']['head']) ? '' : $v['source']['head'] . '/180'; $ret[$k]['retweeted_status']['original_pic'] = empty($v['source']['image']) ? '' : $v['source']['image']; $ret[$k]['retweeted_status']['reposts_count'] = empty($v['source']['count']) ? 0 : $v['source']['count']; $ret[$k]['retweeted_status']['comments_count'] = empty($v['source']['mcount']) ? 0 : $v['source']['mcount']; } } } } } else { $ret['error'] = empty($result['errcode']) ? "empty" : $result['errcode']; } // print_r($result);exit; return $ret; } else { return "无可用分享信息,请重新登录"; } }