Created
February 5, 2014 17:24
-
-
Save bactisme/8828895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
# pip install requests | |
import requests | |
from requests.auth import HTTPBasicAuth | |
def get_distributors(base_url, auth): | |
print "--- GET HOTELS" | |
url = base_url + "/api/distributors.json" | |
r = requests.get(url, auth=auth) | |
print r.text | |
def post_distributor(base_url, auth): | |
print "--- POST HOTEL" | |
url = base_url + "/api/distributors/4.json" | |
data = { | |
"distributor[name]" : "Nokiqsd", | |
"distributor[subtitle]" : "qsdNml", | |
"distributor[description]" : "mlkNMDR" | |
} | |
r = requests.put(url, data=data, auth=auth) | |
print "-> " + str(r.status_code) | |
print r.text | |
auth=HTTPBasicAuth('apiuser', 'ryan') | |
b = "http://localhost:8888/symtest/Symfony/web/app_dev.php" | |
get_distributors(b,auth) | |
post_distributor(b, auth) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment