12 April 2012
llHTTPRequest
cannot follow.
The main problem with Name2Key
, third-party providers is that their websites are not reliable. Ultimately, by using a third-party website sets you at the mercy of their service. They, in turn, are set at the mercy of many parameters and may at any time cease to provide service. If you have a script that relies on their service, you are basically subscribing and increasing the dependency of your script on their website.
This however varies depending on the website. Say, for example, that you would be able to retrieve the key directly from the Second Life website. In this case, if the website went down, it would most probably take the whole of Second Life with it and your script would be worthless during that event anyway.
The main script in this article [K] N2K
, uses the World Wide Web Consortium website to extract they keys of avatar names. Concerning prestige, the W3C website is, simply put, the international standards organization for the World Wide Web. In this context, it is safe to assume that their services will not go down any time soon. If it does, then it would be equally safe to assume that the whole Internet just went down, internationally.
Also, it is wise to know, that if your script uses these third-party services, you contribute to their wealth indirectly since their websites get hits from all your scripts for free. Users acquainted with SEO methodologies will realize immediately that such websites make money by the bunch, implicitly just by the number of hits which ranks their website very high on all search engines.
By using the script below, you do transfer the same prestige to the World Wide Web Consortium. However, since they are the people who, in layman terms, define web standards, it feels more like giving the prestige back. Also, it is worth mentioning that the World Wide Web Consortium roughly scores a Google Page Rank of 10, which is the maximum one can achieve.
There are many third-party databases available, most of them can be found on the llKey2Name
. Each of them offer Name2Key
in exchange for hits and they are all unreliable since they permanently change. The best example for that is a script Failsavename2key
which attempts to contact them all in the hope that not all of them are down.
There have been several JIRA requests made, and a few suggested LSL functions to be implemented so you may retrieve the name of an avatar from a key.
As a general rule, it is recommended that you avoid using name2key scripts since regardless how prestigious the website may be, you are still adding a third party dependency to your scripts.
Augren Ferguson pointed out that agents choosing not to register their avatars with the search system will not be available using N2K. I think that is a decent choice to to opt out for the sake of one's privacy.
llTextBox
to enter your name.
The tester script [K] N2K - Tester
uses llTextBox
, however this might not yet be implemented by all viewers. The tester script itself is not needed for the functionality of the name2key
system. In any case, if you are a developer looking to include a name2key system, and your viewer doesn't implement llTextBox
yet, you will know how to perform your own tests.
The script listens for link messages with the string parameter str
containing the name of the avatar and answers with a link message (to the primitive that sent the link message in the first place) having the key parameter set to the key it retrieved or the NULL_KEY
in case the avatar key could not be found.
Here is an example rundown of a communication between two scripts. The request comes from a primitive having the link number 1, and sends the request to the N2K script in a primitive in the same linkset having the link number 7:
llMessageLinked(7, 0, "Morgan LeFay", ""); <--- requests the key of the avatar Morgan LeFay ... llMessageLinked(1, 0, "KN2K", "1ad33407-a792-476d-a5e3-06007c0802bf"); <--- the key being sent back
The script expects the full-name of the avatar. If you are looking for a "new member", they apparently do not have last names. "New members" do have last names and they are all "Resident". So if you are looking for a new user called "John", you should pass "John Resident" to the script.
Although very elaborate methods such as proxies, logging of SL in-world keys and downright to search engine translation hacks have been previously used to retrieve the key of an avatar, this script simply uses the html2text service provided by the World Wide Consortium to load the http://vwrsearch.secondlife.com website after it has been passed the name of the avatar.
This has the advantage that it strips most HTML out, leaving the secondlife
protocol link well within the bounds of the llHTTPRequest()
2KB data return limit in case the avatar key has been found.
////////////////////////////////////////////////////////// // Wizardry and Steamworks - 2011, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // ////////////////////////////////////////////////////////// key kReq; integer lReqNum; default { link_message(integer sender_num, integer num, string str, key id) { lReqNum = sender_num; kReq = str; state kn2k; } } state kn2k { state_entry() { llSetTimerEvent(.8); } timer() { llSetTimerEvent(0); kReq = llHTTPRequest("http://www.w3.org/services/html2txt?url=" + llEscapeURL("http://vwrsearch.secondlife.com/client_search.php?session=00000000-0000-0000-0000-000000000000&q=") + llEscapeURL(kReq), [], ""); } http_response(key request_id, integer status, list metadata, string body) { key avKey; if(request_id == kReq && status == 200) if(avKey = llList2Key(llParseString2List(body, ["secondlife:///app/agent/", "/about"], []),1)) { llMessageLinked(lReqNum, 0, "KN2K", avKey); state default; } llMessageLinked(lReqNum, 0, "KN2K", NULL_KEY); state default; } }
/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// default { state_entry() { llListen(-7, "", llGetOwner(), ""); llTextBox(llGetOwner(), "\nType the name of an avatar to retrieve the key:", -7); } listen(integer channel, string name, key id, string message) { llMessageLinked(LINK_THIS, 0, message, ""); } link_message(integer sender_num, integer num, string str, key id) { if(str == "KN2K") llTextBox(llGetOwner(), "\nType the name of an avatar to retrieve the key:" + "\n\nYour last search result: " + (string)id, -7); } }