Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Upload a photo using the Ning API
- """
- import oauth2 as oauth
- import ningapi
- consumer = oauth.Consumer(
- key="0d716e57-5ada-4b29-a33c-2f4af1b26837",
- secret="f0963fa5-1259-434f-86fc-8a17d14b16ca"
- )
- token = oauth.Token(
- key="07aa5613-6783-4735-b8f1-4c69642ad438",
- secret="e2c528ec-8b81-402c-8f88-8bf17ba8751f"
- )
- host = "external.ningapis.com"
- network = "apiexample"
- ning_api = ningapi.Client(host, network, consumer, token)
- photo_title = "Photo Title"
- photo_desc = "Photo Description"
- photo_path = "/Users/devin/Pictures/nasa/NASA-23.jpg"
- photo_content_type = "image/jpeg"
- photo_fields = {
- "title": photo_title,
- "description": photo_desc,
- "file": photo_path,
- "content_type": photo_content_type
- }
- content = ning_api.post("Photo", photo_fields)
- if content["success"]:
- print "Photo uploaded: %s" % content["id"]
Advertisement
Add Comment
Please, Sign In to add comment