我目前有我的代码的上传部分工作,我将如何将其转换为将从 box 文件夹中下载相应文件的程序?
这是上传程序:
import requests
import json
#the user acces token
access_token = 'UfUNeHhv4gIxFCn5WEXHgBJwfG8gHT2o'
#the name of the file as you want it to appear in box
dst_filename = 'box_file'
#the actual file path
src_directory = 'C:\Python\cache\\'
#the name of the file to be transferred
src_filename = 'Wildlife.wmv'
#the id of the folder you want to upload to
parent_id = '0'
counter = 1
for counter in range(1, 6):
src_file = (src_directory + src_filename + '-' + str(counter))
print(src_file) …Run Code Online (Sandbox Code Playgroud) 我正在尝试从Stem项目中获取To Love With Toto乐队。
from io import StringIO
import socket
import urllib3
import time
import socks # SocksiPy module
import stem.process
from stem.util import term
SOCKS_PORT = 9150
# Set socks proxy and wrap the urllib module
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
socket.socket = socks.socksocket
# Perform DNS resolution through the socket
def getaddrinfo(*args):
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
socket.getaddrinfo = getaddrinfo
def query(url):
"""
Uses urllib to fetch a site using SocksiPy for Tor over the SOCKS_PORT. …Run Code Online (Sandbox Code Playgroud) 我正在尝试开始使用Box.com SDK,我有几个问题.
from boxsdk import OAuth2
oauth = OAuth2(
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
store_tokens=your_store_tokens_callback_method,
)
auth_url, csrf_token = oauth.get_authorization_url('http://YOUR_REDIRECT_URL')
def store_tokens(access_token, refresh_token):
# store the tokens at secure storage (e.g. Keychain)
Run Code Online (Sandbox Code Playgroud)
1)什么是重定向网址以及如何使用它?我是否需要运行服务器才能使用它?
2)我在store_tokens方法中需要什么样的代码?