当前位置: 首页>>代码示例>>Python>>正文


Python Facebook.auth_token方法代码示例

本文整理汇总了Python中facebook.Facebook.auth_token方法的典型用法代码示例。如果您正苦于以下问题:Python Facebook.auth_token方法的具体用法?Python Facebook.auth_token怎么用?Python Facebook.auth_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在facebook.Facebook的用法示例。


在下文中一共展示了Facebook.auth_token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_facebook_api

# 需要导入模块: from facebook import Facebook [as 别名]
# 或者: from facebook.Facebook import auth_token [as 别名]
def get_facebook_api(request):
	"""
		This will return None on failure (we call this from places where we know there's no API -- responsible for checking None condition on other IFs)
	"""
	from jjmaker.models import get_user_profile, new_user_profile
	fb = Facebook(settings.FACEBOOK_API_KEY, settings.FACEBOOK_SECRET_KEY)

	# Use the data from the cookie if present
	try:
		auth_token = get_facebook_access_token(request)
	except:
		auth_token = request.GET.get('auth_token', None)

	try:
		fb.auth_token = auth_token
		userprofile_id = get_facebook_uid(request)
	except KeyError, MultiValueDictKeyError:
		traceback.print_exc()
		fb = None
开发者ID:zeroaltitude,项目名称:jj,代码行数:21,代码来源:jotjournal_utils.py

示例2: web_app

# 需要导入模块: from facebook import Facebook [as 别名]
# 或者: from facebook.Facebook import auth_token [as 别名]
def web_app(request):
    """Get the user's friends and their pictures. This example uses
       the Django web framework, but should be adaptable to others."""

    # Get api_key and secret_key from a file
    fb_file = open('facebook_keys.txt').readlines()
    api_key = fb_file[0].strip()
    secret_key = fb_file[1].strip()
    fb = Facebook(api_key, secret_key)

    # Use the data from the cookie if present
    if 'session_key' in request.session and 'uid' in request.session:
        fb.session_key = request.session['session_key']
        fb.uid = request.session['uid']
    else:
        
        try:
            fb.auth_token = request.GET['auth_token']
        except KeyError:
            # Send user to the Facebook to login
            return HttpResponseRedirect(fb.get_login_url())

        # getSession sets the session_key and uid
        # Store these in the cookie so we don't have to get them again
        fb.auth.getSession()
        request.session['session_key'] = fb.session_key
        request.session['uid'] = fb.uid

    try:
        friend_ids = fb.friends.get()
    except FacebookError, e:
        # Error 102 means the session has expired.
        # Delete the cookie and send the user to Facebook to login
        if e.info['code'] == u'102':
            del request.session['session_key']
            del request.session['uid']
            return HttpResponseRedirect(fb.get_login_url())
        else:
            # Other Facebook errors are possible too. Don't ignore them.
            raise
开发者ID:RockHoward,项目名称:pyfacebook,代码行数:42,代码来源:examples.py


注:本文中的facebook.Facebook.auth_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。