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

From Second Life Wiki
Jump to navigation Jump to search
m (unsigned comment)
Line 6: Line 6:


{{unsigned|Chinny Iwish|10:01, 6 August 2008}}
{{unsigned|Chinny Iwish|10:01, 6 August 2008}}
== Obsolete info moved from article ==
I moved the following information, which I believe is outdated from the article.  Archiving here for a time to confirm there is nothing that should be kept.
Additionally, the link to the Java implementation did not resolve when I tried to download it today.
--[[User:Rand Linden|Rand Linden]] 00:21, 14 February 2009 (UTC)
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 [[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.
--[[User:Ingmar Rasmuson|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);
}

Revision as of 16:21, 13 February 2009

We had discovered an issue with the example code with line 121 on llsd.php.

if (!$dom = domxml_open_mem($str, DOMXML_LOAD_PARSING, $error))

Apparently php5 does not support this function (domxml_open_mem), but a workaround can be found here [1] which enables php5 to use domxml.

—The preceding unsigned comment was added on 10:01, 6 August 2008 by Chinny Iwish

Obsolete info moved from article

I moved the following information, which I believe is outdated from the article. Archiving here for a time to confirm there is nothing that should be kept.

Additionally, the link to the Java implementation did not resolve when I tried to download it today. --Rand Linden 00:21, 14 February 2009 (UTC)

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);
}