1#!/bin/perl
2# 15.4.2008, Sampo Kellomaki (sampo@symlabs.com)
3
4use Net::SSLeay;
5use MIME::Base64;
6use Data::Dumper;
7
8$out  = "Content-Type: text/html\n\n<h1>Orange API Tester</h1>";
9$out .= "<i><b>Powered by <a href=\"http://zxid.org/\">ZXID.org</a></b></i>\n";
10$out .= qq(<p>[<a href="/protected/saml?o=gl">Local Logout</a>][<a href="/protected/saml?o=gr">Logout All</a>][<a href="/protected/saml?o=m">Mgmt</a>][<a href="/protected/orange.cgi">Redo</a>]);
11
12#print Dumper %ENV;
13#$tok = 'B64ZykVc8LgIlcwgLgOkFaASPMPSo5cp+q1Acbb4cnDZbCedIfYw9cllz89a2Ql+Pn4fGf8uhX2j4iH7PojzB57ppzrbv0ECxG+SzNewsjk0kU=|sau=|ted=1208280413|Lq7LWxp8KX2EaPPo3gQIRcWiSJA=';
14
15$tok = $ENV{'SAML_OrangeAPIToken'};
16$tok =~ s/\+/%2b/gs;
17
18$myurl = 'https://sp1.zxidsp.org:5443/protected/orange.cgi';
19$myurl =~ s|([/:?&])|sprintf("%%%02x", ord($1))|gsex;
20$host = 'personal.alpha.orange-api.net';
21#$user = 'https://sp1.zxidsp.org:8443/zxidhlo?o=B';
22#$user = 'https%3a//sp1.zxidsp.org%3a8443/zxidhlo?o=B';
23#$user = 'ZXIDHELLOT1184204761';
24$user = 'ZXIDHELLOT5882485470';
25$pass = '5)CIlpCG';
26
27$out .= <<HTML;
28<p>Host: $host<br>
29User: $user<br>
30Pass: $pass<br>
31Tok: $tok<br>
32MyURL: $myurl
33HTML
34    ;
35
36# https://personal.alpha.orange-api.net/int/PersonalPhotos/V1
37# https://personal.alpha.orange-api.net/int/PersonalContacts/V1
38# https://personal.alpha.orange-api.net/int/PersonalMessages/V1
39# https://personal.alpha.orange-api.net/int/PersonalCalendar/V1
40
41@t = (
42      '/int/PersonalContacts/V1?action=addcontact&lastname=Koerkki&firstname=Janne&nickname=koerkkicompany=ACME&function=Tester&department=Test+Lab&emailperso=koerkki@acme.com',
43      '/int/PersonalContacts/V1?action=findcontactlist&search=Res',
44      '/int/PersonalContacts/V1?action=findcontactlist&search=koe',
45      '/int/PersonalContacts/V1?action=getcontact&cid=123',
46      '/int/PersonalContacts/V1?action=getcontact&cid=456',
47      '/int/PersonalMessages/V1?action=getPNS&infos=NoUnReadMails,NoEMails',
48      '/int/PersonalCalendar/V1?action=addevent&title=Demo+meet&location=Townhall&description=Come+all+and+see+the+demo&startdate=2008-05-09&starttime=13:40&enddate=2008-05-09&endtime=14:15&datepattern=yyyy-MM-dd&timepattern=HH:mm',
49      );
50
51for $test (@t) {
52    ++$i;
53    ($page, $result, %headers)
54	= Net::SSLeay::get_https($host, 443, "$test&token=$tok",
55		    Net::SSLeay::make_headers(Authorization =>
56				 'Basic ' . MIME::Base64::encode("$user:$pass",''))
57		    );
58    warn "GET $test\n$result\n";
59    if ($page =~ /PrivacyAccessDeniedException/) {
60	($url) = $page =~ /<url>(.*)<\/url>/;
61	$url =~ s/&amp;/&/gs;
62	warn "REDIRECT url($url)";
63	print "Location: $url&urlRetour=$myurl%3FfromOrangePrivacy%3Dtrue\n\n";
64	exit;
65    }
66    $out .= "<h3>Test $i</h3>\n<pre>GET $test\n$result\n</pre><textarea cols=100 rows=15>$page</textarea>\n";
67}
68
69print $out;
70print qq(<hr><a href="http://zxid.org/"><img src="http://zxid.org/button-zxid-150x60.png" width=150 height=60 border=0></a>\n);
71
72__END__
73
74https://personal.alpha.orange-api.net/int/PersonalContacts/V1?action=findcontactlist&search=Res&token=B649bqepYsSgyeG0YEqRfaqZfKepqqXA/MNWrq26wmyNg7DGqvq0XFg14sPAPCKxR0+j9rt+3KqcZC1kZXKam0Y0FWpbTeZSExLsvCThURos5Q=|sau=|ted=1208277327|lZNyzAFHF95wGIzT8+drVAaz1+k=
75
76https://personal.alpha.orange-api.net/int/PersonalContacts/V1?action=findcontactlist&search=Res&token=B641JdSYmhqWQWIVe182/49MDWdr8vuesUdovzJm7uxzUFns7K55ADEASBSST8PNHox7vwoxAu2BwOrdOo7xVbUV6Uzyd36inXKiE6/tWINxlc=|sau=|ted=1208277986|ysJgx5YVaxtZgs/N/bvNObbgLTE=
77
78https://personal.alpha.orange-api.net/int/PersonalContacts/V1?action=findcontactlist&search=Res&token=
79
80https://personal.alpha.orange-api.net/int/PersonalContacts/V1?action=findcontactlist&search=Res&token=
81
82https://personal.alpha.orange-api.net/int/PersonalContacts/V1?action=findcontactlist&search=Res&token=
83
84https://sp1.zxidsp.org:8443/zxidhlo?o=B
855)CIlpCG
86
87
88
89/privacy/interaction.do?family=contact&serviceId=DEMOSPUSIN1653032205&attributes=,add
90&urlRetour=http%3A%2F%2F161.105.181.114%2FphpOrangeApiConsumer%2Fdemo%2Fresto%2FTonResto.com%2FEclaireur%2FEclaireur.php%3FfromOrangePrivacy%3Dtrue
91
92
93Orange API Tester
94============ 1 ===========
95/int/PersonalContacts/V1?action=findcontactlist&search=Res
96HTTP/1.1 500 Internal Server Error
97<?xml version="1.0" encoding="UTF-8"?><error><!--Warning : operation non autorisee--><code>-3</code><detail>PrivacyAccessDeniedException</detail><url>http://int4.mdsp.rec.orange.fr/privacy/interaction.do?family=contact&amp;serviceId=ZXIDHELLOT1184204761&amp;attributes=,see</url></error>
98
99
100http://int4.mdsp.rec.orange.fr/privacy/interaction.do?family=contact&amp;serviceId=ZXIDHELLOT1184204761&amp;attributes=,see
101
102
103<error>
104  <code>-3</>
105  <detail>PrivacyAccessDeniedException</>
106  <url>
107    http://int4.mdsp.rec.orange.fr/privacy/interaction.do?family=contact&serviceId=ZXIDHELLOT1184204761&attributes=,see</></>
108
109
110
111
112
113http://int4.mdsp.rec.orange.fr/privacy/interaction.do?family=contact&serviceId=ZXIDHELLOT5882485470&attributes=,add
114