• No results found

The JSON approach is mainly intended for intranet integration, while the xml version is for machine to machine integration.

N/A
N/A
Protected

Academic year: 2021

Share "The JSON approach is mainly intended for intranet integration, while the xml version is for machine to machine integration."

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

1881 Partner Search API

The Partner Search API is a RESTFull service that utilizes the HTTP/GET verb. Parameters are passed

in the querystring of the HTTP request. The service can produce both xml and JSON formatted data.

The JSON approach is mainly intended for intranet integration, while the xml version is for machine

to machine integration.

Search:

Parameter name

Mandatory

Description

serviceId

Yes

The service id is assigned to the customer by 1881

userName

Yes

The user name assigned to the customer by 1881

password

Yes

The password assigned to the customer by 1881

msisdn

Yes

The a-number of the end-user performing the

search

query

Yes

The search query. Should be url encoded

format

No

Set this to json for JSON formatted data

level

No

Defines the amount of data to return

catalogueIds

No

Catalogueid=0; public person listings

Catalogueid=1; public company listings

Catalogueid=5; internal catalogue

If this is empty, all available catalogues is included

the list of id’s is separated by |

page

No

The page so return in the result set, if empty the

first page will be shown.

geoCodes

no

Geo code pairs separated with |

Pair is presented in the following way:

Latitude:Longitude

Lat/long is encoded like 62.7836

Example:

62.7836:7.367456|62.7346: 5.4736

Invalid formatted geocodes will be ignored.

Example:

/search?userName=########&msisdn=########&password=*****&query=opplysningen&l evel=0&format=json

Serarch result

Field name

Description

StatusMessage

Contains an error message if the search fails, otherwise empty

TotalNumberOfResults The number of hits

Results

The actual hits

(2)

Parameter name

Mandatory

Description

serviceId

Yes

The service id is assigned to the customer by 1881

userName

Yes

The user name assigned to the customer by 1881

password

Yes

The password assigned to the customer by 1881

msisdn

Yes

The a-number of the end-user performing the

search

format

No

Set this to json for JSON formatted data

Example:

/GetCatalogues?

userName=########&msisdn=########&password=*****&format=json Result: <?xml version="1.0"?> <SearchLists xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://1881.no/api/PartnerSearch"> <SearchableCatalogues> <SearchList> <CatalogueId>0</CatalogueId>

<CatalogueName>1881.no - Person</CatalogueName> </SearchList>

<SearchList>

<CatalogueId>1</CatalogueId>

<CatalogueName>1881.no - Bedrift</CatalogueName> </SearchList>

<SearchList>

<CatalogueId>5</CatalogueId>

<CatalogueName>Internkatalog</CatalogueName> </SearchList>

<SearchList>

<CatalogueId>36</CatalogueId>

<CatalogueName>Kunder</CatalogueName> </SearchList>

<SearchList>

<CatalogueId>37</CatalogueId> <CatalogueName>Test</CatalogueName> </SearchList>

</SearchableCatalogues> </SearchLists>

(3)

.net proxy

1881 has developed a proxy for the service with strong typed message classes. The class library

(O1881.PartnerSearch.Proxy.dll) can be downloaded from 1881.no.

The client proxy only supports .net 4.0 and 4.5.x.

var query = new SearchQuery

{ Msisdn = "########", Password = "******", QueryLevel = QueryLevels.Maximum, UserName = "########", Query = "opplysningen" };

using (var target = new SearchProxy()) {

var result = target.GetResult(ApiUrl, query); //TODO: do something with the result

}

Table 1: 1881 search

using (var target = new SearchProxy())

{

var request = new SearchCataloguesRequest

{

Msisdn = "

########

",

Password = "

########

",

UserName = "

########

"

};

SearchLists actual;

actual = target.GetSearchCatalogues(new Uri(ApiUrl), request);

//do something with the catalogues

}

Table 2: Get catalogues

AppSetings:

ApiUrl :

https://api.1881bedrift.no/search

ServiceId: service id assigned from 1881

UserName: username assigned from 1881

Password: password assigned from 1881

(4)

Jqery sample:

<script type="text/javascript" language="javascript"> var userName = "########";

var msisdn = "########"; var password = "*****";

$(document).ready(function () {

//need to user charset=ISO-8859-1 in order to get Norwegian characters correct to the search service.

$("#QueryBox").autocomplete({

source: function (request, response) { $.ajax({

contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1", url: GetSearchUrl(),

type: "GET", dataType: "json",

success: function (data) { response($.map(data.Results, function (item) {

return { label: GetName(item) + "(" + GetPhone(item) + ")", value: GetName(item), code: GetPhone(item) };

})) }

, error: function (data)

{ $("#Phone")[0].innerText = "an error occured while readring search service"; } })

},

select: function (data) {

$("#Code").value = data.item; $("#Phone").val(data.item); }, minLength: 1 }) }); function GetName(item) { if (item.CompanyName != null) return item.CompanyName;

return item.FirstName + " " + item.LastName; }

function GetSearchUrl() {

var data = "/search?userName=" + userName + "&msisdn=" + msisdn + "&password=" + password + "&query="

+ $.URLEncode($("#QueryBox").val()) + "&level=0&format=json";

$("#SearchUrl")[0].innerText = data; return data;

}

function GetPhone(item) {

if (item.ContactPoints == null) return "";

for (var i = 0; i < item.ContactPoints.length; i++) { if (item.ContactPoints[i].ContactPointType == 2) return item.ContactPoints[i].Address; }

return ""; }

$("#QueryBox").bind("autocompleteselect", function (event, ui) { $("#Code").val(ui.item.label);

$("#Phone")[0].innerText = ui.item.code; });

(5)

var o = ''; var x = 0; c = c.toString(); var r = /(^[a-zA-Z0-9_.]*)/; while (x < c.length) {

var m = r.exec(c.substr(x));

if (m != null && m.length > 1 && m[1] != '') { o += m[1]; x += m[1].length;

} else {

if (c[x] == ' ') o += '+'; else {

var d = c.charCodeAt(x); var h = d.toString(16); o += '%' + (h.length < 2 ? '0' : '') + h.toUpperCase(); } x++; } } return o; }, URLDecode: function (s) {

var o = s; var binVal, t; var r = /(%[^%]{2})/;

while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') { b = parseInt(m[1].substr(1), 16); t = String.fromCharCode(b); o = o.replace(m[1], t); } return o; } }); </script>

Example result set:

<?xml version="1.0"?> <SearchResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://1881.no/api/PartnerSearch"> <ExtensionData /> <CurrentPage>0</CurrentPage> <Pages>0</Pages> <Results> <ResultItem> <ExtensionData /> <Addresses> <Address1 xsi:nil="true" /> </Addresses> <BirthDate xsi:nil="true" /> <Collection>B2B</Collection> <ContactPoints> <ContactPoint1> <ExtensionData /> <Address>+47+4793257288</Address>

<ContactPointType>Mobile</ContactPointType> </ContactPoint1>

<ContactPoint1> <ExtensionData />

<Address>[email protected]</Address> <ContactPointType>Email</ContactPointType> </ContactPoint1>

<ContactPoint1> <ExtensionData />

<Address>+47+4798855641</Address>

<ContactPointType>Mobile</ContactPointType> </ContactPoint1>

<ContactPoint1> <ExtensionData />

<Address>www.pragma.no</Address>

<ContactPointType>HomePage</ContactPointType> </ContactPoint1>

</ContactPoints>

<FirstName>Jonas</FirstName> <Gender>Unknown</Gender> <LastName>Syrstad</LastName> <ResultType>Person</ResultType> </ResultItem>

</Results>

<TotalNumberOfResults>1</TotalNumberOfResults> </SearchResponse>

References

Related documents

Impacts of Recent Submarine Cable Cuts on Middle East Internet.. Doug Madory, Renesys Corp

´ PVC requires reciprocating screw injection moulding machine with a plasticising screw to produce homogeneous melt.. ´ It is recommended that a shot weight of the part should take

Recurrent programmes (excl. Reruns, sports events, programmes aired less than 3 times, programmes shorter than 3 minutes)... guests in DVR- or IPTV-households,

Carmina Escobar is a singer and multimedia artist from Mexico City who has engaged with a diverse set of musical styles, including medieval music, opera, contemporary music,

The next three chapters will give you the “lay of the land” about why I chose Ace Hardware as my role model for this book; why I picked this company to showcase these 52

The Automated Systems Optimization solution from CHEP —the company that knows more about how pallets work with automated equipment than anyone else — ensures that you get the

Since Mansfield, as a pioneer, proposed technology diffusion model incorporating the rate of imitation and technology adoption, a variety of growth curves such as the

Human Anatomy &amp; Physiology: Skeletal System; Ziser, Lecture Notes, 2014.2 53. on surface