An API is provided by an overseas crowdsourcing site called CloudFlower, and I'm stuck when I try to use it.
Terminal
curl -X POST --data-urlencode "job[title]={some_title}" --data-urlencode "job[instructions]={some_instructions}" https://api.crowdflower.com/v1/jobs.json?key={api_key}
by http://success.crowdflower.com/customer/portal/articles/1553902
Hmm? I know ? Key = {api_key}
as a URL query, but what is --data-urlencode
?
--data-urlencode data Posts data like any other --data option, except for HTTP URL encoding. (7.18.0 or later) To conform to CGI, the data part starts with name, puts a delimiter, and then continues to specify the content. The format of the data part is as follows: content The content is URL-encoded and then POSTed. Make sure that the content does not contain the characters = or @. It will match one of the formats below! =content The content is URL-encoded and then POSTed. The first character = is not included in the data. name=content The content part is URL-encoded and then POSTed. Note that the name part is already considered URL-encoded. @filename This will make curl load data from the given file (including any newlines), URL-encode that data and pass it on in the POST. The data is read into curl (including line breaks) from the given file, URL-encoded and then POSTed. name@filename The data is read into curl (including line breaks) from the given file, URL-encoded and then POSTed. An equal sign is added to the name part to form the contents of the name = URL-encoded file. Note that the name part is already considered URL-encoded.
Well, is it an option used when posting data as well as URL parameters? (That is the same as the parameter?)
In this case, the pattern of name = content
.
... just send it as a parameter normally !!
curl2requests.py
import requests
def main():
payload={'key':APIKey,'job[title]':'Awesome','job[instructions]':'Welcome'}
r = requests.post("https://api.crowdflower.com/v1/jobs.json",params=payload)
if __nama__='__main__':
main()
did it!!
It is doubtful that patterns other than name = content
can be safely used> <
curl.1 man page Requests HTTP for humans
Recommended Posts