So, I am working with a code block that interacts with the Flickr API.
I get a "syntax error" in xml.parsers.expat.ExpatError (below). Now I can not understand how this will be a syntax error in the Python module.
I saw another similar SO question regarding the Wikipedia API, which seemed to return HTML instead of XML. The Flickr API returns XML; and I also get the same error when there should be no response from Flickr (e.g. flickr.galleries.addPhoto )
CODE:
def _dopost(method, auth=False, **params):
trace of TRACEBACK calls:
Traceback (most recent call last): File "TESTING.py", line 30, in <module> flickr.galleries_create('test_title', 'test_descriptionn goes here.') File "/home/vlad/Documents/Computers/Programming/LEARNING/curatr/flickr.py", line 1006, in galleries_create primary_photo_id=primary_photo_id) File "/home/vlad/Documents/Computers/Programming/LEARNING/curatr/flickr.py", line 1066, in _dopost return _get_data(minidom.parse(urlopen(url, payload))) File "/usr/lib/python2.6/xml/dom/minidom.py", line 1918, in parse return expatbuilder.parse(file) File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 928, in parse result = builder.parseFile(file) File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 207, in parseFile parser.Parse(buffer, 0) xml.parsers.expat.ExpatError: syntax error: line 1, column 62
(Code from http://code.google.com/p/flickrpy/ under the new BSD license)
UPDATE:
print urlopen(url, payload) == <addinfourl at 43340936 whose fp = <socket._fileobject object at 0x29400d0>>
Running urlopen(url, payload).read() returns HTML that is hard to read in the terminal: P, but I managed to parse "You are not logged in."
The weird part is that Flickr should not return anything here, or if permissions are a problem, it should return error 99: User not logged in / Insufficient permissions , as is the case with the GET function (which I expected would be in valid XML).
I connected to Flickr (in the browser) and the program was correctly authenticated with delete permissions (dangerous, but I wanted to avoid permission problems.)