Difference between revisions of "Linden Lab Official:Reg API Examples"

From Second Life Wiki
Jump to navigation Jump to search
(Added note about license on LLSD-Java)
(Reworked entry about LLSD implementation in Java)
Line 8: Line 8:
  Add: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  Add: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);


--[[User:Xugu Madison|Xugu Madison]] 21:21, 10 September 2008 (BST):
A Java implementation of LLSD and RegAPI is available at http://archipelago.cs.st-andrews.ac.uk/llsd-java/src/llsd-java-0.2.1.zip . Code written by [[User:Xugu Madison|Xugu Madison]], copyright held by [http://www.st-andrews.ac.uk/ University of St Andrews], and made available under the [http://www.opensource.org/licenses/bsd-license.php BSD] license.
I've got a simple LLSD and RegAPI implementation written in Java, which we use locally. You can grab a copy at http://archipelago.cs.st-andrews.ac.uk/llsd-java/src/llsd-java-0.2.zip (licensed as GPL v2).


--[[User:Ingmar Rasmuson|Ingmar Rasmuson]] 02:16, 23 May 2007 (PDT):  
--[[User:Ingmar Rasmuson|Ingmar Rasmuson]] 02:16, 23 May 2007 (PDT):  

Revision as of 08:48, 15 September 2008

Back to RegAPI Main Page

Linden Lab provided sample code is here:

  • Examples
  • Downloads
    • NOTE- the LLSD library has a bug and a new version will be released on 5/21.
    • Add the following line to the function llsd_post_string().
Add: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

A Java implementation of LLSD and RegAPI is available at http://archipelago.cs.st-andrews.ac.uk/llsd-java/src/llsd-java-0.2.1.zip . Code written by Xugu Madison, copyright held by University of St Andrews, and made available under the BSD license.

--Ingmar Rasmuson 02:16, 23 May 2007 (PDT): In addition to the patch I suggested, have a look at the CURL debug section I proposed. It might come in handy when debugging the SSL communication (citing my email to LLB):

As you know, this took me some time to figure out, so perhaps others could benefit from this solution, too:

I've added a

// Enable curl debug messages, off by default
define("CURL_DEBUG",   FALSE);

at the beginning of the API library for turning CURL debugging on and off and altered the llsd_post_string() function in this way:

function llsd_post_string($url, $str)
{
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 curl_setopt($ch, CURLOPT_POST, TRUE);
//suggested patch - start
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//suggested patch - end
 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/xml"));
 curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
 $doc = curl_exec($ch);
 $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//suggested debug section - start
 if (CURL_DEBUG)
 {
  print_r(curl_getinfo($ch),"CURL getinfo()"); 
  echo "URL error number: " .curl_errno($ch); 
  echo "URL error: " . curl_error($ch); 
 }
//suggested debug section - end
curl_close($ch);
 
return llsd_decode($doc);
}