从Algorithmia运行自动标记

时间:2015-07-06 18:30:09

标签: python curl tags algorithmia

我尝试从Algorithmia运行自动标记,主要尝试使用func pad(fps:Float, currentFrame:Float) -> (String){ var fps = fps var frame = currentFrame + f var ff = frame % fps var seconds = s + ((currentFrame) / fps) var ss = seconds % 60 var minutes = m + ((seconds - ss) / 60) var mm = minutes % 60 var hh = h + ((minutes - mm) / 60) return "\(showTwoDigits(hh)):\(showTwoDigits(mm)):\(showTwoDigits(ss)):\(showTwoDigits(ff))" } func showTwoDigits(number:Float) -> (String){ var string = ("00" + String(format:"%.f", number)) var range = Range(start: (advance(string.endIndex, -2)), end: string.endIndex) var cutStr = string.substringWithRange(range) return cutStr } cURL,并收到错误消息:

卷曲

Pyhton

的Python

{"error":{"message":"authorization required"}}

我做错了什么?

感谢。

2 个答案:

答案 0 :(得分:2)

根据documentation for AutoTag,您希望在发送请求之前将授权信息作为标题包含在您的请求中。

以下是他们的例子:

import urllib2, json
input = ["rails","rails"]
request = urllib2.Request('https://api.algorithmia.com/v1/algo/tags/AutoTagGithub/0.1.1')
request.add_header('Content-Type', 'application/json')
request.add_header('Authorization', 'Simple sim11111111111111111123456789abcdef')
response = urllib2.urlopen(request, json.dumps(input))
print response.read()

如果您正在关注他们的示例(因为它看起来像你),我建议您使用自己的令牌代替sim11111111111111111123456789abcdef

答案 1 :(得分:0)

PyPi上的Algorithmia python client允许直接设置API密钥:

import Algorithmia

input = ["rails","rails"]
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('tags/AutoTagGithub/0.1.4')
print algo.pipe(input)