Beispiel #1
0
 public function get_reply_tweet($tweet_status_id)
 {
     $reply_to_id = false;
     if (empty($tweet_status_id)) {
         return $reply_to_id;
     }
     $tweet = new ucm_twitter_message($this, false);
     $tweet->load_by_twitter_id($tweet_status_id);
     return $tweet->get('social_twitter_message_id');
     /*
     		// check if it exists in the database already:
     		$exists = get_single('social_twitter_message','twitter_message_id',$tweet_status_id);
     		if(!$exists || $exists['twitter_message_id'] != $tweet_status_id){
     			// grab from api and save in database.
     			$tmhOAuth = $this->get_api();
     			$twitter_code = $tmhOAuth->user_request(array(
     				'url' => $tmhOAuth->url('1.1/statuses/show'),
     				'params' => array(
     			      'id' => $tweet_status_id,
     			    ),
     			));
     			if ($twitter_code == 200) {
     				$tweet = json_decode( $tmhOAuth->response['response'], true );
     				//echo 'reply';print_r($tweet);exit;
     				$new_reply_to_id = 0;
     				if(isset($tweet['in_reply_to_status_id_str']) && !empty($tweet['in_reply_to_status_id_str'])){
     					// import / find reply tweeet from db or api:
     					$new_reply_to_id = $this->get_reply_tweet($tweet['in_reply_to_status_id_str']);
     				}
     				$type = _TWITTER_MESSAGE_TYPE_OTHERTWEET;
     				if(isset($tweet['in_reply_to_user_id_str']) && $tweet['in_reply_to_user_id_str'] == $this->get('twitter_id')){
     					$type = _TWITTER_MESSAGE_TYPE_MENTION;
     				}else if(isset($tweet['user']['id_str']) && $tweet['user']['id_str'] == $this->get('twitter_id')){
     					$type = _TWITTER_MESSAGE_TYPE_MYTWEET;
     				}
     				update_insert('social_twitter_message_id',false, 'social_twitter_message', array(
     					'social_twitter_id' => $this->social_twitter_id,
     					'reply_to_id' => $new_reply_to_id,
     					'twitter_message_id' => $tweet['id_str'],
     					'twitter_from_id' => isset($tweet['user']['id_str']) ? $tweet['user']['id_str'] : '',
     					'twitter_from_name' => isset($tweet['user']['screen_name']) ? $tweet['user']['screen_name'] : '',
     					'twitter_to_id' => isset($tweet['in_reply_to_user_id_str']) ? $tweet['in_reply_to_user_id_str'] : '',
     					'twitter_to_name' => isset($tweet['in_reply_to_screen_name']) ? $tweet['in_reply_to_screen_name'] : '',
     					'summary' => isset($tweet['text']) ? $tweet['text'] : '', //todo: swap out shortened urls in 'entities' array.
     					'message_time' => isset($tweet['created_at']) ? strtotime($tweet['created_at']) : '',
     					'data' => json_encode($tweet),
     					'type' =>$type,
     				));
     			}
     		}else{
     			$reply_to_id = $exists['social_twitter_message_id'];
     		}
     
     		return $reply_to_id;*/
 }