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


Python pocket.Pocket类代码示例

本文整理汇总了Python中pocket.Pocket的典型用法代码示例。如果您正苦于以下问题:Python Pocket类的具体用法?Python Pocket怎么用?Python Pocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: dispatch

 def dispatch(self, request, *args, **kwargs):
     if not request.session.get('access_token'):
         request_token = Pocket.get_request_token(consumer_key=settings.CONSUMER_KEY)
         request.session['request_token'] = request_token
         auth_url = Pocket.get_auth_url(code=request_token, redirect_uri='http://localhost:8000/token')
         return HttpResponseRedirect(auth_url)
     return super(HomeView, self).dispatch(request, *args, **kwargs)
开发者ID:Undauted,项目名称:Practice-getpocket,代码行数:7,代码来源:views.py

示例2: get_client

    def get_client(self):
        """
        Connects to Pocket API using OAuth
        """
        request_token = pckt.get_request_token(
            consumer_key=self.consumer_key,
            redirect_uri=self.REDIRECT_URI
        )
        log.debug(request_token)

        # URL to redirect user to, to authorize your app
        auth_url = pckt.get_auth_url(
            code=request_token,
            redirect_uri=self.REDIRECT_URI
        )
        log.debug(auth_url)

        # only needed to authorize your app the first time
        #request_token2 = input('request token: ')

        if not self.access_token:
            self.access_token = pckt.get_access_token(
                consumer_key=self.consumer_key, code=request_token)
            log.debug(self.access_token)

        return pckt(
            consumer_key=self.consumer_key,
            access_token=self.access_token)
开发者ID:uranther,项目名称:kipy,代码行数:28,代码来源:pocket.py

示例3: delete_item

def delete_item(item_id):
    access_token = wf.get_password('pocket_access_token')
    pocket_instance = Pocket(CONSUMER_KEY, access_token)
    try:
        pocket_instance.delete(item_id, wait=False)
        return 'Link deleted'
    except ConnectionError:
        return 'Connection error'
开发者ID:moaa,项目名称:alfred-pocket,代码行数:8,代码来源:pocket_launcher.py

示例4: get_request_token

def get_request_token():
    consumer_key = get_consumer_key()
    request_token = Pocket.get_request_token(consumer_key = consumer_key)
    auth_url = Pocket.get_auth_url(code=request_token)
    os.system('open "{0}"'.format(auth_url))
    time.sleep(5)

    return request_token
开发者ID:kchnr,项目名称:getpocket-to-epub,代码行数:8,代码来源:pocket_utils.py

示例5: archive_item

def archive_item(item_id):
    access_token = WF.get_password('pocket_access_token')
    pocket_instance = Pocket(config.CONSUMER_KEY, access_token)
    try:
        pocket_instance.archive(item_id, wait=False)
        return 'Link archived'
    except PocketException:
        return 'Connection error'
开发者ID:hbcbh1999,项目名称:alfred-pocket,代码行数:8,代码来源:pocket_launcher.py

示例6: form_valid

 def form_valid(self, form):
     pocket_instance = Pocket(settings.CONSUMER_KEY, self.request.session['access_token'])
     file = self.request.FILES['file']
     for url in file.readlines():
         pocket_instance.add(url.decode().rstrip())
         # pocket_instance.bulk_add(item_id='', url=url.decode().rstrip())
     # pocket_instance.commit()
     return super(HomeView, self).form_valid(form)
开发者ID:Undauted,项目名称:Practice-getpocket,代码行数:8,代码来源:views.py

示例7: connect_to_pocket

def connect_to_pocket(request):
    redirect_uri = request.build_absolute_uri(reverse('feed_pocket_success'))
    request_token = Pocket.get_request_token(
        consumer_key=settings.POCKET_CONSUMER_KEY,
        redirect_uri=redirect_uri)
    auth_url = Pocket.get_auth_url(code=request_token,
                                   redirect_uri=redirect_uri)
    request.user.profile.pocket_request_token = request_token
    request.user.profile.save()
    return HttpResponseRedirect(auth_url)
开发者ID:kodchi,项目名称:pocketfeed,代码行数:10,代码来源:views.py

示例8: push_to_pocket

def push_to_pocket(link_id):
    link = Document.find_one({'user': g.user._id, '_id': ObjectId(link_id)})
    if link:
        user = User.find_one({'_id': link.user})
        pocket_instance = Pocket(POCKET_APP_TOKEN,
                                 user.credentials['pocket']['token'])
        pocket_instance.add(link.url, wait=False)
        link.read = True
        link.save()
    return "OK"
开发者ID:Lothiraldan,项目名称:feedlight,代码行数:10,代码来源:app.py

示例9: pocket_login

def pocket_login():
    """Calling into authorize will cause the OpenID auth machinery to kick
    in.  When all worked out as expected, the remote application will
    redirect back to the callback URL provided.
    """
    redirect_uri = url_for('pocket_authorized', _external=True)
    request_token = Pocket.get_request_token(consumer_key=POCKET_APP_TOKEN,
                                             redirect_uri=redirect_uri)
    session['request_token'] = request_token
    return redirect(Pocket.get_auth_url(code=request_token,
                                        redirect_uri=redirect_uri))
开发者ID:Lothiraldan,项目名称:feedlight,代码行数:11,代码来源:app.py

示例10: add_item

def add_item(item):
    if item is not None:
        access_token = wf.get_password('pocket_access_token')
        pocket_instance = Pocket(config.CONSUMER_KEY, access_token)
        try:
            pocket_instance.add(
                url=item['url'], title=item['title'], tags="alfred")
            return True
        except InvalidQueryException:
            pass
    return False
开发者ID:hbcbh1999,项目名称:alfred-pocket,代码行数:11,代码来源:pocket_save.py

示例11: auth

def auth():
    pocket = Pocket(config.POCKET_CONSUMER_KEY, config.BASE_URL +
            url_for('auth_callback'))
    try:
        code = pocket.get_request_token()
        url = pocket.get_authorize_url(code)
    except APIError as apie:
        return str(apie)
    session.pop('code', None)
    session['code'] = code
    return redirect(url)
开发者ID:c4pt0r,项目名称:pocket-bookmark,代码行数:11,代码来源:main.py

示例12: send_to_pocket

def send_to_pocket(url):
    if mconfig:
        if 'share_settings' in mconfig:
            if 'pocket' in mconfig['share_settings']:
                pocket_config = mconfig['share_settings']['pocket']
                pc = Pocket(
                    consumer_key=pocket_config['consumer_key'],
                    access_token=pocket_config['access_token']
                )
                return pc.add( url=url )
        else:
            return {"status":0,"message":"Pocket not configured."}
    else:
        return {"status":0,"message":"No configuration file found."}
开发者ID:m82labs,项目名称:murrow,代码行数:14,代码来源:topocket.py

示例13: auth

    def auth(self, request):
        """
            let's auth the user to the Service
        """
        callback_url = "http://%s%s" % (request.get_host(), reverse("pocket_callback"))

        request_token = Pocket.get_request_token(consumer_key=self.consumer_key, redirect_uri=callback_url)

        # Save the request token information for later
        request.session["request_token"] = request_token

        # URL to redirect user to, to authorize your app
        auth_url = Pocket.get_auth_url(code=request_token, redirect_uri=callback_url)

        return auth_url
开发者ID:sidaga,项目名称:django-th,代码行数:15,代码来源:my_pocket.py

示例14: delete_item

def delete_item(item_id):
    access_token = WF.get_password('pocket_access_token')
    pocket_instance = Pocket(config.CONSUMER_KEY, access_token)
    try:
        pocket_instance.delete(item_id, wait=False)

        # remove entry in cache
        item_list = WF.cached_data('pocket_list', max_age=0)
        if type(item_list) is list and len(item_list) > 0:
            item_list[:] = [
                d for d in item_list if d.get('item_id') != item_id]
            WF.cache_data('pocket_list', item_list)

        return 'Link deleted'
    except PocketException:
        return 'Connection error'
开发者ID:hbcbh1999,项目名称:alfred-pocket,代码行数:16,代码来源:pocket_launcher.py

示例15: callback

    def callback(self, request):
        """
            Called from the Service when the user accept to activate it
        """

        try:
            # finally we save the user auth token
            # As we already stored the object ServicesActivated
            # from the UserServiceCreateView now we update the same
            # object to the database so :
            # 1) we get the previous object
            us = UserService.objects.get(
                user=request.user,
                name=ServicesActivated.objects.get(name='ServicePocket'))
            # 2) then get the token
            access_token = Pocket.get_access_token(
                consumer_key=self.consumer_key,
                code=request.session['request_token'])

            us.token = access_token
            # 3) and save everything
            us.save()
        except KeyError:
            return '/'

        return 'pocket/callback.html'
开发者ID:pouete,项目名称:django-th,代码行数:26,代码来源:my_pocket.py


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