本文整理汇总了Python中twython.Twython.destroy_saved_search方法的典型用法代码示例。如果您正苦于以下问题:Python Twython.destroy_saved_search方法的具体用法?Python Twython.destroy_saved_search怎么用?Python Twython.destroy_saved_search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twython.Twython
的用法示例。
在下文中一共展示了Twython.destroy_saved_search方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TwythonAPITestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import destroy_saved_search [as 别名]
#.........这里部分代码省略.........
# Multi add/delete members
self.api.create_list_members(list_id=list_id,
screen_name='johncena,xbox')
self.api.delete_list_members(list_id=list_id,
screen_name='johncena,xbox')
# Single add/delete member
self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
self.api.delete_list_member(list_id=list_id, screen_name='justinbieber')
self.api.delete_list(list_id=list_id)
def test_get_list_memberships(self):
'''Test list of lists the authenticated user is a member of succeeds'''
self.api.get_list_memberships()
def test_get_list_subscribers(self):
'''Test list of subscribers of a specific list succeeds'''
self.api.get_list_subscribers(list_id=test_list_id)
def test_subscribe_is_subbed_and_unsubscribe_to_list(self):
'''Test subscribing, is a list sub and unsubbing to list succeeds'''
self.api.subscribe_to_list(list_id=test_list_id)
# Returns 404 if user is not a subscriber
self.api.is_list_subscriber(list_id=test_list_id,
screen_name=screen_name)
self.api.unsubscribe_from_list(list_id=test_list_id)
def test_is_list_member(self):
'''Test returning if specified user is member of a list succeeds'''
# Returns 404 if not list member
self.api.is_list_member(list_id=test_list_id, screen_name='jack')
def test_get_list_members(self):
'''Test listing members of the specified list succeeds'''
self.api.get_list_members(list_id=test_list_id)
def test_get_specific_list(self):
'''Test getting specific list succeeds'''
self.api.get_specific_list(list_id=test_list_id)
def test_get_list_subscriptions(self):
'''Test collection of the lists the specified user is
subscribed to succeeds'''
self.api.get_list_subscriptions(screen_name='twitter')
def test_show_owned_lists(self):
'''Test collection of lists the specified user owns succeeds'''
self.api.show_owned_lists(screen_name='twitter')
# Saved Searches
def test_get_saved_searches(self):
'''Test getting list of saved searches for authenticated
user succeeds'''
self.api.get_saved_searches()
def test_create_get_destroy_saved_search(self):
'''Test getting list of saved searches for authenticated
user succeeds'''
saved_search = self.api.create_saved_search(query='#Twitter')
saved_search_id = saved_search['id_str']
self.api.show_saved_search(id=saved_search_id)
self.api.destroy_saved_search(id=saved_search_id)
# Places & Geo
def test_get_geo_info(self):
'''Test getting info about a geo location succeeds'''
self.api.get_geo_info(place_id='df51dec6f4ee2b2c')
def test_reverse_geo_code(self):
'''Test reversing geocode succeeds'''
self.api.reverse_geocode(lat='37.76893497', long='-122.42284884')
def test_search_geo(self):
'''Test search for places that can be attached
to a statuses/update succeeds'''
self.api.search_geo(query='Toronto')
def test_get_similar_places(self):
'''Test locates places near the given coordinates which
are similar in name succeeds'''
self.api.get_similar_places(lat='37', long='-122', name='Twitter HQ')
# Trends
def test_get_place_trends(self):
'''Test getting the top 10 trending topics for a specific
WOEID succeeds'''
self.api.get_place_trends(id=1)
def test_get_available_trends(self):
'''Test returning locations that Twitter has trending
topic information for succeeds'''
self.api.get_available_trends()
def test_get_closest_trends(self):
'''Test getting the locations that Twitter has trending topic
information for, closest to a specified location succeeds'''
self.api.get_closest_trends(lat='37', long='-122')
示例2: TwitterHelper
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import destroy_saved_search [as 别名]
#.........这里部分代码省略.........
logger.info(append_response)
segment += 1
logger.info('[MyTwitter] Finalize')
finalize_params = {
"command": "FINALIZE",
"media_id": media_id,
}
self.twitter.post(url, finalize_params)
return media_id
def get_trending_topics_for(self, woeids):
trending_topics = []
for woeid in woeids:
trends = self.twitter.get_place_trends(id=woeid)[0].get('trends', [])
for trend in trends:
trending_topics.append(trend['name'])
return trending_topics
def get_saved_searches(self):
saved_searches = []
searches = self.twitter.get_saved_searches()
for srch in searches:
saved_searches.append(srch['name'])
return saved_searches
def delete_saved_searches(self):
searches = self.twitter.get_saved_searches()
for srch in searches:
self.twitter.destroy_saved_search(id=srch["id_str"])
def search(self, text, result_type="popular"):
query = quote_plus(text)
return self.twitter.search(q=query, result_type=result_type)["statuses"]
@retry(**retry_args)
def favourite(self, id_str):
try:
self.twitter.create_favorite(id=id_str)
self.identity.statistics.record_favourite()
except TwythonError as ex:
if "You have already favourited this tweet" in str(ex):
logger.warning(ex)
else:
raise
@retry(**retry_args)
def retweet(self, id_str):
try:
self.twitter.retweet(id=id_str)
self.identity.statistics.record_retweet()
except TwythonError as ex:
if "You have already retweeted this tweet" in str(ex):
logger.warning(ex)
else:
raise
@retry(**retry_args)
def add_user_to_list(self, list_id, user_id, screen_name):
self.twitter.create_list_members(list_id=list_id, user_id=user_id, screen_name=screen_name)
@retry(**retry_args)
示例3: TwythonAPITestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import destroy_saved_search [as 别名]
#.........这里部分代码省略.........
# Multi add/delete members
self.api.create_list_members(list_id=list_id,
screen_name=screen_names)
self.api.delete_list_members(list_id=list_id,
screen_name=screen_names)
# Single add/delete member
self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
self.api.delete_list_member(list_id=list_id, screen_name='justinbieber')
self.api.delete_list(list_id=list_id)
def test_get_list_subscribers(self):
"""Test list of subscribers of a specific list succeeds"""
self.api.get_list_subscribers(list_id=test_list_id)
def test_subscribe_is_subbed_and_unsubscribe_to_list(self):
"""Test subscribing, is a list sub and unsubbing to list succeeds"""
self.api.subscribe_to_list(list_id=test_list_id)
# Returns 404 if user is not a subscriber
self.api.is_list_subscriber(list_id=test_list_id,
screen_name=screen_name)
self.api.unsubscribe_from_list(list_id=test_list_id)
def test_is_list_member(self):
"""Test returning if specified user is member of a list succeeds"""
# Returns 404 if not list member
self.api.is_list_member(list_id=test_list_id, screen_name='jack')
def test_get_list_members(self):
"""Test listing members of the specified list succeeds"""
self.api.get_list_members(list_id=test_list_id)
def test_get_specific_list(self):
"""Test getting specific list succeeds"""
self.api.get_specific_list(list_id=test_list_id)
def test_get_list_subscriptions(self):
"""Test collection of the lists the specified user is
subscribed to succeeds"""
self.api.get_list_subscriptions(screen_name='twitter')
def test_show_owned_lists(self):
"""Test collection of lists the specified user owns succeeds"""
self.api.show_owned_lists(screen_name='twitter')
# Saved Searches
def test_get_saved_searches(self):
"""Test getting list of saved searches for authenticated
user succeeds"""
self.api.get_saved_searches()
def test_create_get_destroy_saved_search(self):
"""Test getting list of saved searches for authenticated
user succeeds"""
saved_search = self.api.create_saved_search(query='#Twitter')
saved_search_id = saved_search['id_str']
self.api.show_saved_search(id=saved_search_id)
self.api.destroy_saved_search(id=saved_search_id)
# Places & Geo
def test_get_geo_info(self):
"""Test getting info about a geo location succeeds"""
self.api.get_geo_info(place_id='df51dec6f4ee2b2c')
def test_reverse_geo_code(self):
"""Test reversing geocode succeeds"""
self.api.reverse_geocode(lat='37.76893497', long='-122.42284884')
def test_search_geo(self):
"""Test search for places that can be attached
to a statuses/update succeeds"""
self.api.search_geo(query='Toronto')
def test_get_similar_places(self):
"""Test locates places near the given coordinates which
are similar in name succeeds"""
self.api.get_similar_places(lat='37', long='-122', name='Twitter HQ')
# Trends
def test_get_place_trends(self):
"""Test getting the top 10 trending topics for a specific
WOEID succeeds"""
self.api.get_place_trends(id=1)
def test_get_available_trends(self):
"""Test returning locations that Twitter has trending
topic information for succeeds"""
self.api.get_available_trends()
def test_get_closest_trends(self):
"""Test getting the locations that Twitter has trending topic
information for, closest to a specified location succeeds"""
self.api.get_closest_trends(lat='37', long='-122')
# Help
def test_get_application_rate_limit_status(self):
"""Test getting application rate limit status succeeds"""
self.oauth2_api.get_application_rate_limit_status()
示例4: TwyAPI
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import destroy_saved_search [as 别名]
class TwyAPI(object):
def __init__(self, request):
self.request = request
@view_config(route_name='callback', renderer='json')
def callback(self):
oauth_verifier = self.request.GET['oauth_verifier']
OAUTH_TOKEN = self.request.cookies['oauth_token']
OAUTH_TOKEN_SECRET = self.request.cookies['oauth_token_secret']
twitter = Twython(APP_KEY, APP_SECRET,
OAUTH_TOKEN,
OAUTH_TOKEN_SECRET)
final_step = twitter.get_authorized_tokens(oauth_verifier)
OAUTH_TOKEN = final_step['oauth_token']
OAUTH_TOKEN_SECRET = final_step['oauth_token_secret']
# set cookies and redirect
response = HTTPFound(location='https://twittpane-dev.freegate.co')
response.set_cookie('oauth_token', OAUTH_TOKEN, max_age=86400)
response.set_cookie('oauth_token_secret', OAUTH_TOKEN_SECRET, max_age=86400)
return response
@view_config(route_name='home', renderer='templates/home.jinja2')
def home(self):
if self.validate_auth() == False:
self.auth()
return {'project': 'twittpane'}
@view_config(route_name='auth')
def auth(self):
self.twitter = Twython(APP_KEY, APP_SECRET)
auth = self.twitter.get_authentication_tokens(callback_url=CALLBACK_URL)
OAUTH_TOKEN = auth['oauth_token']
OAUTH_TOKEN_SECRET = auth['oauth_token_secret']
auth_url = auth['auth_url']
# set cookies and redirect
response = HTTPFound(location=auth_url)
response.set_cookie('oauth_token', OAUTH_TOKEN, max_age=86400)
response.set_cookie('oauth_token_secret', OAUTH_TOKEN_SECRET, max_age=86400)
return response
@view_config(route_name='validate_auth')
def validate_auth(self):
if 'oauth_token' in self.request.cookies and 'oauth_token_secret' in self.request.cookies:
OAUTH_TOKEN = self.request.cookies['oauth_token']
OAUTH_TOKEN_SECRET = self.request.cookies['oauth_token_secret']
self.twitter = Twython(APP_KEY, APP_SECRET,
OAUTH_TOKEN,
OAUTH_TOKEN_SECRET)
return True
else:
return False
@view_config(route_name='verify_credentials')
def verify_credentials(self):
if not hasattr(self, 'twitter'):
if not self.validate_auth():
return None
try:
return self.twitter.verify_credentials()
except TwythonError as e:
return {"verify_credentials": e}
@view_config(route_name='get_saved_searches')
def get_saved_searches(self):
if not hasattr(self, 'twitter'):
if self.validate_auth() == False:
return None
try:
return self.twitter.get_saved_searches()
except TwythonError as e:
return {"get_saved_searches": e}
@view_config(route_name='create_saved_search')
def create_saved_search(self):
if not hasattr(self, 'twitter'):
if self.validate_auth() == False:
return None
try:
params = self.request.GET.dict_of_lists()
return self.twitter.create_saved_search(**params)
except TwythonError as e:
return {"create_saved_search": e}
@view_config(route_name='destroy_saved_search')
def destroy_saved_search(self):
if not hasattr(self, 'twitter'):
if self.validate_auth() == False:
return None
try:
#id_str = self.request.params['id']
params = {'id': self.request.params['id']}
print(params)
return self.twitter.destroy_saved_search(**params)
except TwythonError as e:
return {"destroy_saved_search": e}
#.........这里部分代码省略.........
示例5: TwythonEndpointsTestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import destroy_saved_search [as 别名]
#.........这里部分代码省略.........
screen_name='themattharris')
@unittest.skip('skipping non-updated test')
def test_get_list_members(self):
"""Test listing members of the specified list succeeds"""
self.api.get_list_members(slug=test_list_slug,
owner_screen_name=test_list_owner_screen_name)
@unittest.skip('skipping non-updated test')
def test_get_specific_list(self):
"""Test getting specific list succeeds"""
self.api.get_specific_list(slug=test_list_slug,
owner_screen_name=test_list_owner_screen_name)
@unittest.skip('skipping non-updated test')
def test_get_list_subscriptions(self):
"""Test collection of the lists the specified user is
subscribed to succeeds"""
self.api.get_list_subscriptions(screen_name='twitter')
@unittest.skip('skipping non-updated test')
def test_show_owned_lists(self):
"""Test collection of lists the specified user owns succeeds"""
self.api.show_owned_lists(screen_name='twitter')
# Saved Searches
@unittest.skip('skipping non-updated test')
def test_get_saved_searches(self):
"""Test getting list of saved searches for authenticated
user succeeds"""
self.api.get_saved_searches()
@unittest.skip('skipping non-updated test')
def test_create_get_destroy_saved_search(self):
"""Test getting list of saved searches for authenticated
user succeeds"""
saved_search = self.api.create_saved_search(query='#Twitter')
saved_search_id = saved_search['id_str']
self.api.show_saved_search(id=saved_search_id)
self.api.destroy_saved_search(id=saved_search_id)
# Places & Geo
@unittest.skip('skipping non-updated test')
def test_get_geo_info(self):
"""Test getting info about a geo location succeeds"""
self.api.get_geo_info(place_id='df51dec6f4ee2b2c')
@unittest.skip('skipping non-updated test')
def test_reverse_geo_code(self):
"""Test reversing geocode succeeds"""
self.api.reverse_geocode(lat='37.76893497', long='-122.42284884')
@unittest.skip('skipping non-updated test')
def test_search_geo(self):
"""Test search for places that can be attached
to a statuses/update succeeds"""
self.api.search_geo(query='Toronto')
@unittest.skip('skipping non-updated test')
def test_get_similar_places(self):
"""Test locates places near the given coordinates which
are similar in name succeeds"""
self.api.get_similar_places(lat='37', long='-122', name='Twitter HQ')
# Trends