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

From Second Life Wiki
Jump to navigation Jump to search
Line 4: Line 4:
* [http://secondlife.com/developers/third_party_reg/#examples Examples]
* [http://secondlife.com/developers/third_party_reg/#examples Examples]
* [http://secondlife.com/developers/third_party_reg/#downloads Downloads]
* [http://secondlife.com/developers/third_party_reg/#downloads 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 [[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);
}




[[Category:RegAPI|Sample Code]]
[[Category:RegAPI|Sample Code]]
[[Category:Web Service APIs]]
[[Category:Web Service APIs]]

Revision as of 17:18, 13 February 2009