这是一个 test.py 文件,它尝试将数据发送到 api 端点:
import os
import requests
import uuid
def get_uid():
return str(uuid.uuid4())
oauth_consumer_key = 'abcd'
oauth_signature = 'efgh'
oauth_signature_method = 'PLAINTEXT'
oauth_timestamp ='132798314211'
oauth_nonce = get_uid() + "aa"
oauth_token_secret = ""
x_auth_mode = 'client_auth'
x_auth_username = ''
x_auth_password = ''
userid = ''
instagram_id = "asdas"
instagram_token = "asdas"
params = {
'oauth_consumer_key':oauth_consumer_key,
'oauth_signature':oauth_signature,
'oauth_signature_method':oauth_signature_method,
'oauth_timestamp': oauth_timestamp,
'oauth_nonce': get_uid(),
'instagram_id' : instagram_id,
'instagram_token':instagram_token,
}
url = 'http://localhost:8000/instagram/signin/'
data = {'instagram_id':instagram_id,'instagram_token':instagram_token}
r = requests.post(url,params)
print r.content
这是我的测试处理程序:
class TestHandler(AnonymousBaseHandler):
def read(self,request,action=None):
"""Get request to get the instagram code
"""
print action
if action == "signin":
return "hello121"
#self.instagram_signin(request)
def instagram_signin(self,request):
"""
Check if the instagram user exists in the database
"""
return "Yes!"
是的,就这么基本,它返回一个错误:
File "/usr/local/lib/python2.7/dist-packages/django_piston-0.3dev-py2.7.egg/piston/handler.py", line 105, in create
except self.model.DoesNotExist:
AttributeError: 'TestHandler' object has no attribute 'model'
该应用程序已在 settings.py 中注册。我已经多次完成了syncdb。重新启动服务器。重新启动系统,仍然无法解决这个问题。