Skip to content

Instantly share code, notes, and snippets.

@bactisme
Created February 5, 2014 17:24
Show Gist options
  • Save bactisme/8828895 to your computer and use it in GitHub Desktop.
Save bactisme/8828895 to your computer and use it in GitHub Desktop.
#!/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