#!/bin/perl
# 15.4.2008, Sampo Kellomaki (sampo@symlabs.com)
use Net::SSLeay;
use MIME::Base64;
use Data::Dumper;
$out = "Content-Type: text/html\n\n<h1>Orange API Tester</h1>";
$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>]);
#print Dumper %ENV;
#$tok = 'B64ZykVc8LgIlcwgLgOkFaASPMPSo5cp+q1Acbb4cnDZbCedIfYw9cllz89a2Ql+Pn4fGf8uhX2j4iH7PojzB57ppzrbv0ECxG+SzNewsjk0kU=|sau=|ted=1208280413|Lq7LWxp8KX2EaPPo3gQIRcWiSJA=';
$tok = $ENV{'SAML_OrangeAPIToken'};
$tok =~ s/\+/%2b/gs;
$myurl =~ s|([/:?&])|sprintf("%%%02x", ord($1))|gsex;
$host = 'personal.alpha.orange-api.net';
#$user = 'https%3a//sp1.zxidsp.org%3a8443/zxidhlo?o=B';
#$user = 'ZXIDHELLOT1184204761';
$user = 'ZXIDHELLOT5882485470';
$pass = '5)CIlpCG';
$out .= <<HTML;
<p>Host: $host<br>
User: $user<br>
Pass: $pass<br>
Tok: $tok<br>
MyURL: $myurl
HTML
;
@t = (
'/int/PersonalContacts/V1?action=addcontact&lastname=Koerkki&firstname=Janne&nickname=koerkkicompany=ACME&function=Tester&department=Test+Lab&emailperso=koerkki@acme.com',
'/int/PersonalContacts/V1?action=findcontactlist&search=Res',
'/int/PersonalContacts/V1?action=findcontactlist&search=koe',
'/int/PersonalContacts/V1?action=getcontact&cid=123',
'/int/PersonalContacts/V1?action=getcontact&cid=456',
'/int/PersonalMessages/V1?action=getPNS&infos=NoUnReadMails,NoEMails',
'/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',
);
for $test (@t) {
++$i;
($page, $result, %headers)
= Net::SSLeay::get_https($host, 443, "$test&token=$tok",
Net::SSLeay::make_headers(Authorization =>
'Basic ' . MIME::Base64::encode("$user:$pass",''))
);
warn "GET $test\n$result\n";
if ($page =~ /PrivacyAccessDeniedException/) {
($url) = $page =~ /<url>(.*)<\/url>/;
$url =~ s/&/&/gs;
warn "REDIRECT url($url)";
print "Location: $url&urlRetour=$myurl%3FfromOrangePrivacy%3Dtrue\n\n";
exit;
}
$out .= "<h3>Test $i</h3>\n<pre>GET $test\n$result\n</pre><textarea cols=100 rows=15>$page</textarea>\n";
}
print $out;
__END__
5)CIlpCG
/privacy/interaction.do?family=contact&serviceId=DEMOSPUSIN1653032205&attributes=,add
&urlRetour=http%3A%2F%2F161.105.181.114%2FphpOrangeApiConsumer%2Fdemo%2Fresto%2FTonResto.com%2FEclaireur%2FEclaireur.php%3FfromOrangePrivacy%3Dtrue
Orange API Tester
============ 1 ===========
/int/PersonalContacts/V1?action=findcontactlist&search=Res
HTTP/1.1 500 Internal Server Error
<error>
<code>-3</>
<detail>PrivacyAccessDeniedException</>
<url>