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


Python OpenFacebook.get方法代码示例

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


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

示例1: post

# 需要导入模块: from open_facebook.api import OpenFacebook [as 别名]
# 或者: from open_facebook.api.OpenFacebook import get [as 别名]
	def post(self, request, format=None):
		serializer = FacebookSerializer(data=request.data)
		if serializer.is_valid():
			access_token = serializer.data['access_token']
			facebook = OpenFacebook(access_token)
			try:
				user = User.objects.get(username=facebook.get('me')['id'])
				user.last_name = serializer.data['access_token']
				user.save()
			except ObjectDoesNotExist:
				user = User.objects.create_user(facebook.get('me')['id'])
				user.first_name = 'facebook'
				user.last_name = serializer.data['access_token']
				user.save()
			token = Token.objects.get_or_create(user=user)
			return Response({'token': token[0].key})
		return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:reparadocs,项目名称:KITServer,代码行数:19,代码来源:views.py

示例2: handle_existing_user

# 需要导入模块: from open_facebook.api import OpenFacebook [as 别名]
# 或者: from open_facebook.api.OpenFacebook import get [as 别名]
 def handle_existing_user(self, provider, user, access, info):
     """Here we store the access token for the facebook page that we got from facebook."""
     if len(Token.objects.all()) < 5:
         fb = OpenFacebook(access.access_token.split("=")[1])
         me = fb.get('me/accounts')
         for page in me['data']:
             if 'Roseniuskyrkan' in page.values():
                 token = FacebookAuthorization.extend_access_token(page['access_token'])['access_token']
             
         Token.objects.create(token = token)
     return super(LoginCallback, self).handle_existing_user(provider, user, access, info)
开发者ID:danieka,项目名称:churchplanner,代码行数:13,代码来源:views.py

示例3: code2token

# 需要导入模块: from open_facebook.api import OpenFacebook [as 别名]
# 或者: from open_facebook.api.OpenFacebook import get [as 别名]
	def code2token(self, code):
		me = {}
		www = "https://graph.facebook.com/oauth/access_token?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s"%(settings.FACEBOOK_APP_ID, self.redirect_uri, settings.FACEBOOK_APP_SECRET, code)
		response = cgi.parse_qs(urllib.urlopen(www).read())
		access_token = response['access_token'][-1]
		expires = response['expires'][-1]
		#print response
		#print access_token
		#print expires
		graph = OpenFacebook(access_token)
		me = dict(graph.get('me'))

		return access_token, me
开发者ID:szwagier90,项目名称:android_obd,代码行数:15,代码来源:face.py

示例4: save

# 需要导入模块: from open_facebook.api import OpenFacebook [as 别名]
# 或者: from open_facebook.api.OpenFacebook import get [as 别名]
	def save(self, *args, **kwargs):
		from open_facebook.api import OpenFacebook
		from project_dante import settings


		if self.id is None:
			self.member_pk = Profile.objects.get(username="kiasu_bot")
			graph = OpenFacebook(settings.FACEBOOK_APP_ID+'|'+settings.FACEBOOK_APP_SECRET)
			data = graph.get(self.page_link)
			self.page_id = data['id']
			self.page_name = data['name']

		super(FacebookFeed,self).save(*args, **kwargs)
开发者ID:dynoto,项目名称:kiasu-me,代码行数:15,代码来源:models.py

示例5: add_candidate_from_fb

# 需要导入模块: from open_facebook.api import OpenFacebook [as 别名]
# 或者: from open_facebook.api.OpenFacebook import get [as 别名]
def add_candidate_from_fb(request):

    if request.method == 'POST':
        form = FacebookCreateCandidateForm(request.POST)
        if form.is_valid():
            fb = OpenFacebook()
            # fb_url = request.POST.get('fb_page')
            fb_url = form.cleaned_data['url']
            # party = Party.objects.get(id=request.POST.get('party'))
            party = form.cleaned_data['party']
            try:
                res = fb.get(fb_url, fields='name, website, picture.type(large)')
                sites = res.get('website', None).split(' ')
                for site in sites:
                    try:
                        if site == '':
                            continue
                        URLValidator(site)
                        val = site
                        break
                    except ValidationError as e:
                        print site, "is not a valid url"
                        continue

                # add another validation
                c = Candidate(name=res['name'],
                              image_url=res['picture']['data']['url'],
                              personal_site=val,
                              facebook_page=fb_url,
                              party=party)
                c.save()
                messages.info(request, "Added Successfully")
                return redirect(c.get_absolute_url())
            except ParameterException as e:
                messages.error(request, e.message)
    else:
        form = FacebookCreateCandidateForm()

    return render(request,
                  'votes/candidate_fb_form.html',
                  {'form': form})
开发者ID:AriMeidan,项目名称:Fantasy-Knesset,代码行数:43,代码来源:views.py


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