Python django.conf.settings 模块,FACEBOOK_APP_ID 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用django.conf.settings.FACEBOOK_APP_ID

项目:reactnative-backend-base    作者:Seedstars    | 项目源码 | 文件源码
def generate_long_lived_fb_token(access_token, graph_api):
    """Generate a long lived facebook token."""
    params = {
        'grant_type': 'fb_exchange_token',
        'client_id': settings.FACEBOOK_APP_ID,
        'client_secret': settings.FACEBOOK_APP_SECRET,
        'fb_exchange_token': access_token
    }
    connection_name = 'access_token?{}'.format(urllib.parse.urlencode(params))

    try:
        long_lived_fb_token = graph_api.get_connections(id='oauth', connection_name=connection_name)
    except facebook.GraphAPIError:
        raise FacebookInvalidTokenException

    return long_lived_fb_token['access_token']
项目:Instagram    作者:Fastcampus-WPS-5th    | 项目源码 | 文件源码
def authenticate(self, request, facebook_id):
        username = '{}_{}_{}'.format(
            User.USER_TYPE_FACEBOOK,
            settings.FACEBOOK_APP_ID,
            facebook_id,
        )
        try:
            user = User.objects.get(
                user_type=User.USER_TYPE_FACEBOOK,
                username=username
            )
            return user
        except User.DoesNotExist:
            return None
项目:Instagram    作者:Fastcampus-WPS-5th    | 项目源码 | 文件源码
def get_or_create_facebook_user(self, user_info):
        username = '{}_{}_{}'.format(
            self.model.USER_TYPE_FACEBOOK,
            settings.FACEBOOK_APP_ID,
            user_info['id']
        )
        user, user_created = self.get_or_create(
            username=username,
            user_type=self.model.USER_TYPE_FACEBOOK,
            defaults={
                'last_name': user_info.get('last_name', ''),
                'first_name': user_info.get('first_name', ''),
                'email': user_info.get('email', ''),
            }
        )
        # ??? ?? ????? ?? ??? ???? ???
        if user_created and user_info.get('picture'):
            # https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/17190366_634177590104859_7473999312831140266_n.jpg?oh=4c68d08b4066747c1c7c7bcb32670b6a&oe=59DA648E
            # ??? ??? URL
            url_picture = user_info['picture']['data']['url']
            # ?????? ????, ????? ???? ????
            p = re.compile(r'.*\.([^?]+)')
            file_ext = re.search(p, url_picture).group(1)
            file_name = '{}.{}'.format(
                user.pk,
                file_ext
            )
            # Python tempfile
            # https://docs.python.org/3/library/tempfile.html
            # ?????? ????? ????
            temp_file = NamedTemporaryFile()
            # ??? ??? URL? ?? get?? (??? ????)
            response = requests.get(url_picture)
            # ?? ??? temp_file? ??
            temp_file.write(response.content)
            # ImageField? save()???? ???? ?? ??????? ??? ??? ??? ??
            # ???? ???? ??? ?? <??pk.????????> ? ??
            user.img_profile.save(file_name, temp_file)
        return user
项目:Instagram    作者:Fastcampus-WPS-5th    | 项目源码 | 文件源码
def facebook_info(request):
    context = {
        'facebook_app_id': settings.FACEBOOK_APP_ID
    }
    return context
项目:perdiem-django    作者:RevolutionTech    | 项目源码 | 文件源码
def keys(request):
    return {
        'FB_APP_ID': settings.FACEBOOK_APP_ID,
        'GA_TRACKING_CODE': settings.GA_TRACKING_CODE,
        'JACO_API_KEY': settings.JACO_API_KEY,
    }
项目:old-web    作者:cualbondi    | 项目源码 | 文件源码
def facebook_tab(request, *args, **kwargs):
    sr = kwargs['signed_request']
    fb_user_id = None
    if 'user_id' not in sr:
        # el usuario no esta logueado en ponline con fb
        # mostrar en el template un popup con el login de fb
        pass
    else:
        fb_user_id = sr['user_id']
    if 'page' in sr:
        srp = sr['page']
        page_id    = srp['id']
        page_liked = srp['liked']
        page_admin = srp['admin']
    else:
        page_id = request.REQUEST.get('page_id')
        page_liked = request.REQUEST.get('page_liked')
        page_admin = request.REQUEST.get('page_admin')
    try:
        fbps = FacebookPage.objects.filter(id_fb=page_id).values_list('linea_id', flat=True)
        ls = Linea.objects.filter(id__in=fbps)
    except:
        ls = []
    context = {
            'fb_app_id' : settings.FACEBOOK_APP_ID,
            'fb_user_id': fb_user_id,
            'fb_page_id': page_id,
            'fb_page_liked': page_liked,
            'fb_page_admin': page_admin,
            'inside_facebook': True,
            'lineas': ls,
            'user': request.user
        }
    return render_to_response(
        'facebook/tab_lineas.html',
        context,
        context_instance=RequestContext(request)
    )
项目:old-web    作者:cualbondi    | 项目源码 | 文件源码
def facebook_app_id(request):
    return {'FACEBOOK_APP_ID': settings.FACEBOOK_APP_ID}
项目:old-web    作者:cualbondi    | 项目源码 | 文件源码
def aprobar(self, user):
        r = self.recorrido
        if not r.uuid:
            # todavia no existe una version de este recorrido real, que estoy por retirar
            # antes de retirarlo creo su version correspondiente
            rp = RecorridoProposed(
                recorrido       = r,
                nombre          = r.nombre,
                linea           = r.linea,
                ruta            = r.ruta,
                sentido         = r.sentido,
                slug            = r.slug,
                inicio          = r.inicio,
                fin             = r.fin,
                semirrapido     = r.semirrapido,
                color_polilinea = r.color_polilinea,
                pois            = r.pois,
                descripcion     = r.descripcion
            )
            rp.save(user=user)
            self.parent=rp.uuid
            self.save()

        r.recorrido       = self.recorrido
        r.nombre          = self.nombre
        r.linea           = self.linea
        r.ruta            = self.ruta
        r.sentido         = self.sentido
        r.inicio          = self.inicio
        r.fin             = self.fin
        r.semirrapido     = self.semirrapido
        r.color_polilinea = self.color_polilinea
        r.pois            = self.pois
        r.descripcion     = self.descripcion
        r.save()

        try:
            parent = RecorridoProposed.objects.get(uuid=self.parent)
            if parent:
                parent.logmoderacion_set.create(created_by=user,newStatus='R')
        except RecorridoProposed.DoesNotExist:
            pass
        for rp in RecorridoProposed.objects.filter(current_status='S', recorrido=r.recorrido).exclude(uuid=self.uuid):
            rp.logmoderacion_set.create(created_by=user, newStatus='R')
        self.logmoderacion_set.create(created_by=user, newStatus='S')

        #call_command('crear_thumbs', recorrido_id=self.recorrido.id)

        # Notificacion por facebook
        token = urllib2.urlopen('https://graph.facebook.com/oauth/access_token?client_id='+settings.FACEBOOK_APP_ID+'&client_secret='+settings.FACEBOOK_API_SECRET+'&grant_type=client_credentials').read().split('access_token=')[1]
        user = self.get_moderacion_last_user()
        if not user.is_anonymous():
            fb = user.social_auth.filter(provider='facebook')
            if len(fb) != 0:
                from facebook import GraphAPI
                fb_uid = fb[0].uid
                graph = GraphAPI(token)
                graph.request("/"+fb_uid+"/notifications/", post_args={"template":'Felicitaciones! Un moderador aceptó tu edición en cualbondi', "href":"https://cualbondi.com.ar/revision/" + str(self.id) + "/"})