title: How to implement SSDP / UPnP? Trying to use Sony's camera API
body: <p>I'm a total beginner to HTTP requests, but I'd like to write a Python app that uses <a href="http://d.pr/f/gRoD" rel="nofollow">Sony's API</a> for controlling its Wi-Fi cameras. For now, I'm just trying to talk to the camera at all, but my get request keeps failing. I have all the docs (the UPnP documentation, SSDP doc, user's manual, etc.) but I think I'm missing something really fundamental. According to Sony's doc, I need to:</p>
  
  <ol>
  <li>Connect to the camera as an access point (i.e., log in like any other Wi-Fi router)</li>
  <li>Send a request to a certain URL and port</li>
  </ol>
  
  <p>Does anyone have any idea what might be going wrong here? Any good resources on getting started with UPnP / SSDP? I got the formatting for the DISCOVERY_MSG string from <a href="https://gist.github.com/schlamar/2428250" rel="nofollow">here</a>.</p>
  
  <pre><code>#!/usr/bin/python
  
  def main():
      import requests
  
      DISCOVERY_MSG = ('M-SEARCH * HTTP/1.1\r\n' +
                   'HOST: 239.255.255.250:1900\r\n' +
                   'MAN: "ssdp:discover"\r\n' +
                   'MX: 3\r\n' +
                   'ST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\n' +
                   'USER-AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1\r\n\r\n')
  
      try:
          r = requests.get(DISCOVERY_MSG)
      except:
          print('Didn\'t work')
  
  
  if __name__ == '__main__':
    main()
  </code></pre>