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

From Second Life Wiki
Jump to navigation Jump to search
(How to add CURL debug info to API)
m
Line 25: Line 25:
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURLOPT_POST, TRUE);
   curl_setopt($ch, CURLOPT_POST, TRUE);
  //suggest patch - start
  //suggested patch - start
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  //suggested patch - end
  //suggested patch - end

Revision as of 03:52, 23 May 2007

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

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