wboykinm

Photo add using ning API for python

Jul 18th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. """
  2. Upload a photo using the Ning API
  3. """
  4.  
  5. import oauth2 as oauth
  6. import ningapi
  7.  
  8. consumer = oauth.Consumer(
  9.         key="0d716e57-5ada-4b29-a33c-2f4af1b26837",
  10.         secret="f0963fa5-1259-434f-86fc-8a17d14b16ca"
  11.         )
  12. token = oauth.Token(
  13.         key="07aa5613-6783-4735-b8f1-4c69642ad438",
  14.         secret="e2c528ec-8b81-402c-8f88-8bf17ba8751f"
  15.         )
  16.  
  17. host = "external.ningapis.com"
  18. network = "apiexample"
  19.  
  20. ning_api = ningapi.Client(host, network, consumer, token)
  21.  
  22.  
  23. photo_title = "Photo Title"
  24. photo_desc = "Photo Description"
  25. photo_path = "/Users/devin/Pictures/nasa/NASA-23.jpg"
  26. photo_content_type = "image/jpeg"
  27.  
  28. photo_fields = {
  29.         "title": photo_title,
  30.         "description": photo_desc,
  31.         "file": photo_path,
  32.         "content_type": photo_content_type
  33.         }
  34.  
  35. content = ning_api.post("Photo", photo_fields)
  36.  
  37. if content["success"]:
  38.     print "Photo uploaded: %s" % content["id"]
Advertisement
Add Comment
Please, Sign In to add comment