def get_submit_tweet_fb(task_detail): text = task_detail['text'] tweet_type = task_detail['tweet_type'] xnr_user_no = task_detail['xnr_user_no'] es_xnr_result = es.get(index=fb_xnr_index_name, doc_type=fb_xnr_index_type, id=xnr_user_no)['_source'] fb_mail_account = es_xnr_result['fb_mail_account'] fb_phone_account = es_xnr_result['fb_phone_account'] password = es_xnr_result['password'] if fb_phone_account: account_name = fb_phone_account elif fb_mail_account: account_name = fb_mail_account else: account_name = False if account_name: mark = fb_publish(account_name, password, text, tweet_type, xnr_user_no) else: mark = False return mark
def get_submit_tweet_fb(task_detail): print 'get_submit_tweet_fb,start execute=========================' text = task_detail['text'] tweet_type = task_detail['tweet_type'] channel = task_detail['channel'] operate_type = task_detail['operate_type'] xnr_user_no = task_detail['xnr_user_no'] try: es_xnr_result = es.get(index=fb_xnr_index_name, doc_type=fb_xnr_index_type, id=xnr_user_no)['_source'] except Exception as e: print e print es_xnr_result fb_mail_account = es_xnr_result['fb_mail_account'] fb_phone_account = es_xnr_result['fb_phone_account'].strip() password = str(es_xnr_result['password'].strip()) print type(password), password print type('13018119931126731x'), '13018119931126731x' print es.search('fb_xnr', 'user', {}) if fb_phone_account: account_name = str(fb_phone_account) print type(account_name), account_name print type('+8613520874771'), '+8613520874771' elif fb_mail_account: account_name = fb_mail_account else: account_name = False if account_name: print '--------------------------------==================================-------------------------------------------------------' # add params to aliyunredis kn try: fb_tweet_params_dict = {} fb_tweet_params_dict["account_name"] = account_name fb_tweet_params_dict["password"] = password fb_tweet_params_dict["text"] = text fb_tweet_params_dict["tweet_type"] = tweet_type fb_tweet_params_dict["xnr_user_no"] = xnr_user_no fb_tweet_params_dict["channel"] = channel fb_tweet_params_dict["operate"] = operate_type print FB_TWEET_PARAMS, '===================================================fb params' ali_re.lpush(FB_TWEET_PARAMS, json.dumps(fb_tweet_params_dict)) mark = fb_publish(account_name, password, text, tweet_type, xnr_user_no) except Exeption as e: print e #mark = fb_publish('+8613520874771', '13018119931126731x', text, tweet_type, xnr_user_no) else: mark = False return mark
def publish_operate_timing(): query_body = { 'query':{ 'filtered':{ 'filter':{ 'term':{'task_status':0} } } }, 'size':MAX_SEARCH_SIZE } results = es_xnr.search(index=fb_xnr_timing_list_index_name,doc_type=\ fb_xnr_timing_list_index_type,body=query_body)['hits']['hits'] #print 'results::',results if results: for result in results: _id = result['_id'] result = result['_source'] timestamp_set = result['post_time'] print timestamp_set if timestamp_set <= int(time.time()): print '!!' text = result['text'].encode('utf-8') tweet_type = task_source_ch2en[result['task_source']] xnr_user_no = result['xnr_user_no'] # try: # p_url = result['p_url'] # except: # p_url = '' # try: # rank = result['rank'] # except: # rank = u'0' # try: # rankid = result['rankid'] # except: # rankid = '' #r_fid = result['fid'] es_get_result = es_xnr.get(index=fb_xnr_index_name,doc_type=fb_xnr_index_type,id=xnr_user_no)['_source'] fb_mail_account = es_get_result['fb_mail_account'] fb_phone_account = es_get_result['fb_phone_account'] password = es_get_result['password'] if fb_mail_account: account_name = fb_mail_account elif fb_phone_account: account_name = fb_phone_account else: return False mark = fb_publish(account_name, password, text, tweet_type, xnr_user_no) if mark: #task_id = xnr_user_no + '_' + r_fid task_id = _id # item_exist = es_xnr.get(index=fb_xnr_retweet_timing_list_index_name,doc_type=\ # fb_xnr_retweet_timing_list_index_type,id=task_id)['_source'] item_exist = {} item_exist['task_status'] = 1 #item_exist['timstamp_post'] = int(time.time()) es_xnr.update(index=fb_xnr_timing_list_index_name,doc_type=\ fb_xnr_timing_list_index_type,id=task_id,body={'doc':item_exist}) else: continue