1
# -*- coding: utf-8 -*-
3
# Copyright (C) 2007 Youness Alaoui <kakaroto@users.sourceforge.net>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
import xml.sax.saxutils as xml
22
#from pymsn.util.ElementTree import XMLTYPE
24
def soap_header(security_token):
25
"""Returns the SOAP xml header"""
28
<AuthTokenHeader xmlns="http://www.msn.com/webservices/spaces/v1/">
31
</AuthTokenHeader>""" % (xml.escape(security_token))
33
def transport_headers():
34
"""Returns a dictionary, containing transport (http) headers
35
to use for the request"""
40
"""Returns the SOAPAction value to pass to the transport
41
or None if no SOAPAction needs to be specified"""
43
return "http://www.msn.com/webservices/spaces/v1/GetXmlFeed"
45
def soap_body(cid, market = "en-US", max_elements = 2, max_chars = 200, max_images = 6):
46
"""Returns the SOAP xml body"""
47
# , last_viewed, app_id = "Messenger Client 8.0", update_access_time = True, is_active_contact = False
49
<GetXmlFeed xmlns="http://www.msn.com/webservices/spaces/v1/">
51
<cid xmlns="http://www.msn.com/webservices/spaces/v1/">%(cid)s</cid>
52
<storageAuthCache></storageAuthCache>
53
<market xmlns="http://www.msn.com/webservices/spaces/v1/">%(market)s</market>
55
<maxElementCount xmlns="http://www.msn.com/webservices/spaces/v1/">%(max_element_count)d</maxElementCount>
56
<maxCharacterCount xmlns="http://www.msn.com/webservices/spaces/v1/">%(max_character_count)d</maxCharacterCount>
57
<maxImageCount xmlns="http://www.msn.com/webservices/spaces/v1/">%(max_image_count)d</maxImageCount>
62
'max_element_count' : max_elements,
63
'max_character_count' : max_chars,
64
'max_image_count' : max_images}
66
# <applicationId>%(application_id)s</applicationId>
67
# <updateAccessedTime>%(update_accessed_time)s</updateAccessedTime>
68
# <spaceLastViewed>%(space_last_viewed)s</spaceLastViewed>
69
# <isActiveContact>%(is_active_contact)s</isActiveContact>
71
# 'appliation_id' : app_id,
72
# 'update_accessed_time' : XMLTYPE.boolean.encode(update_access_time),
73
# 'space_last_viewed' : last_viewed,
74
# 'is_active_contact' : XMLTYPE.boolean.encode(is_active_contact)
76
def process_response(soap_response):
77
body = soap_response.body
79
response = body.find("./spaces:GetXmlFeedResponse/spaces:GetXmlFeedResult")
81
except AttributeError: