Tham số chuỗi truy vấn python

Tôi không thực sự chắc chắn những gì tôi đang làm. Tôi có nên sử dụng một thư viện cho công việc này không?

Nội dung chính Hiển thị

Vì vậy, tôi đang cố gắng thực hiện một số công việc với API Withings [http. //www. rút tiền. com/api] trong Python

Để thực hiện một số yêu cầu, xác thực OAuth là bắt buộc. Tôi đã trải qua cách sử dụng thư viện yêu cầu và nhận được mã thông báo OAuth và Bí mật, cùng với mã thông báo bí mật người dùng và người dùng của tôi

Bây giờ tôi đang ở thời điểm phải đưa ra yêu cầu và tôi đang gặp phải một số vấn đề. Định dạng cho yêu cầu của tôi cần được thực hiện như sau [một ví dụ từ API của họ]

//wbsapi.withings.net/notify?action=subscribe
&callbackurl=http%3a%2f%2fwww.yourdomain.net%2fyourCustomApplication.php
&comment=Your%20Own%20Application%20Description
&oauth_consumer_key=c331c571585e7c518c78656f41582e96fc1c2b926cf77648223dd76424b52b
&oauth_nonce=accbac1b7ee2b86b828e6dc4a5a539b2
&oauth_signature=XfobZMboIg2cRyNKAvyzONHHnKM%3D
&oauth_signature_method=HMAC-SHA1
&oauth_timestamp=1311842514
&oauth_token=887557411788d5120537c6550fbf2df68921f8dd6f8c7e7f9b441941eb10
&oauth_version=1.0
&userid=831

Theo như tôi có thể nói, đây là một định dạng cấu hình với OAuth, ngoại trừ người dùng ở cuối

Vì vậy, tôi có thể đưa ra yêu cầu như thế này bằng thư viện yêu cầu không?

Bất kỳ sự hỗ trợ nào cũng được đánh giá rất cao, bởi vì tôi đã bị mắc kẹt trong một khoảng thời gian

CHỈNH SỬA

Vì vậy, để làm rõ, tôi hiểu khoảng 98% mã tôi đang được cập nhật. Cuối cùng tôi chỉ gặp một vấn đề nhỏ

Vì vậy, tôi đang ở đây, với mã sau

from __future__ import unicode_literals
from urlparse import parse_qs
import requests
from requests_oauthlib import OAuth2Session

consumer_key = '**Valid consumer key**'

consumer_secret = '**Valid consumer secret**'


oauth_key = '**Valid oauth key obtained through requests library and OAuth workflow**'

oauth_secret ='**Valid oauth secret obtained through requests library and OAuth workflow**'

verifier = '**Valid consumer key obtained through requests library and OAuth workflow**'

base_url = '//wbsapi.withings.net/notify'

params = {
'action': 'subscribe',
'callbackurl': '**callback URL**',
'comment': '**comment**',
'oauth_consumer_key': '**consumer_key**',
'oauth_nonce': 'etc etc',
'oauth_signature' : '' # > requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

5, và sau đó thứ hai là chúng tôi sẽ rút lại
>>> requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

6 và ra khỏi chúng bằng cách sử dụng F-String. Một lần nữa, chỉ cần lưu ý. you will need Python 3. 6 trở lên để sử dụng chúng. Và từ đối tượng
>>> requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

4 đó đang được trả lại, chúng tôi sẽ sử dụng một vài khóa ở đây—một là
>>> requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

5, và sau đó là khóa thứ hai, chúng tôi sẽ kéo lại
>>> requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

6 và in chúng ra bằng cách sử dụng chuỗi f. Một lần nữa, chỉ cần một lưu ý. bạn sẽ cần Python 3. 6 hoặc cao hơn để sử dụng những thứ này

02. 58 Vì vậy, hãy để Lôi lưu và để chạy nó. Vì vậy, hãy lưu và hãy chạy nó

03. 06 Nó đang tìm kiếm ngay bây giờ. Được rồi. Đây là những gì nó quay trở lại. Name kho lưu trữ là

from __future__ import unicode_literals
from urlparse import parse_qs
import requests
from requests_oauthlib import OAuth2Session

consumer_key = '**Valid consumer key**'

consumer_secret = '**Valid consumer secret**'


oauth_key = '**Valid oauth key obtained through requests library and OAuth workflow**'

oauth_secret ='**Valid oauth secret obtained through requests library and OAuth workflow**'

verifier = '**Valid consumer key obtained through requests library and OAuth workflow**'

base_url = '//wbsapi.withings.net/notify'

params = {
'action': 'subscribe',
'callbackurl': '**callback URL**',
'comment': '**comment**',
'oauth_consumer_key': '**consumer_key**',
'oauth_nonce': 'etc etc',
'oauth_signature' : '' # >> requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

48. Nó đang tìm kiếm ngay bây giờ. được rồi. Đây là những gì nó trả lại. Tên kho lưu trữ là
from __future__ import unicode_literals
from urlparse import parse_qs
import requests
from requests_oauthlib import OAuth2Session

consumer_key = '**Valid consumer key**'

consumer_secret = '**Valid consumer secret**'


oauth_key = '**Valid oauth key obtained through requests library and OAuth workflow**'

oauth_secret ='**Valid oauth secret obtained through requests library and OAuth workflow**'

verifier = '**Valid consumer key obtained through requests library and OAuth workflow**'

base_url = '//wbsapi.withings.net/notify'

params = {
'action': 'subscribe',
'callbackurl': '**callback URL**',
'comment': '**comment**',
'oauth_consumer_key': '**consumer_key**',
'oauth_nonce': 'etc etc',
'oauth_signature' : '' # >> requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

8

03. 22 Chúng tôi có thể sửa đổi nó trong chốc lát, cố gắng tìm kiếm một kho lưu trữ khác. Chúng tôi có thể sửa đổi nó một chút, cố gắng tìm kiếm một kho lưu trữ khác

03. 27 Hãy nói rằng chúng tôi đang tìm kiếm ____ 29 và có thể chúng tôi biết

from __future__ import unicode_literals
from urlparse import parse_qs
import requests
from requests_oauthlib import OAuth2Session

consumer_key = '**Valid consumer key**'

consumer_secret = '**Valid consumer secret**'


oauth_key = '**Valid oauth key obtained through requests library and OAuth workflow**'

oauth_secret ='**Valid oauth secret obtained through requests library and OAuth workflow**'

verifier = '**Valid consumer key obtained through requests library and OAuth workflow**'

base_url = '//wbsapi.withings.net/notify'

params = {
'action': 'subscribe',
'callbackurl': '**callback URL**',
'comment': '**comment**',
'oauth_consumer_key': '**consumer_key**',
'oauth_nonce': 'etc etc',
'oauth_signature' : '' # >> requests.get[
...     '//api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... ]

9… và có lẽ chúng ta biết
from __future__ import unicode_literals
from urlparse import parse_qs
import requests
from requests_oauthlib import OAuth2Session

consumer_key = '**Valid consumer key**'

consumer_secret = '**Valid consumer secret**'


oauth_key = '**Valid oauth key obtained through requests library and OAuth workflow**'

oauth_secret ='**Valid oauth secret obtained through requests library and OAuth workflow**'

verifier = '**Valid consumer key obtained through requests library and OAuth workflow**'

base_url = '//wbsapi.withings.net/notify'

params = {
'action': 'subscribe',
'callbackurl': '**callback URL**',
'comment': '**comment**',
'oauth_consumer_key': '**consumer_key**',
'oauth_nonce': 'etc etc',
'oauth_signature' : '' # 

Chủ Đề