Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Srilatha CK
    Using php curl in Custom process
    Topic posted October 14, 2014 by Srilatha CKBlue Ribbon: 750+ Points 
    4068 Views, 22 Comments
    Title:
    Using php curl in Custom process
    Content:

    Hi All,

    I have a requirement where once an incident is solved. I need to send the incident details to external third party system SOAP based webservice call.

    I was trying to use PHP CURL for the same. But curl_exec($ch) is not returning any response neither error.

    Could anyone please let me know if we can really use curl in process designer and were successful in such scenario.

    Thanks,

    Srilatha

    Comment

    • Seeking Solution

      You should use load_curl() function before calling any curl functions. This function load the CURL and enable us to use CURL in program.

    • Srilatha CK

      Thanks for your reply. But we are getting error : Call to undefined function RightNow\CPMObjectEventHandlers..\load_curl()

    • Mark Rhoads

      CPMs are run in their own unique PHP namespace.  load_curl() is in the PHP root namespace.  Try using \load_curl().

    • Bipin Mittal

      Hi Srilatha,

      Yes, it is very much possible to use curl in Custom Process. I hope the below line of code helps:

      load_curl();
      $url='<specify the WSDL URL that you want to access>';
      $cURL = curl_init();
      curl_setopt($cURL,CURLOPT_URL,$url);
      curl_setopt($cURL,CURLOPT_HTTPGET,true);
      curl_setopt($cURL, CURLOPT_RETURNTRANSFER, TRUE);
      $result = curl_exec($cURL);
      curl_close($cURL);

       

      Thanks,

      Bipin
       

    • Srilatha CK

      on using \load_curl()  still getting the same error "Call to undefined function RightNow\CPMObjectEventHandlers..\load_curl()"

      On the same interface Cloud Monitor is working and also Curl libraries are enabled.

    • Gurinderpal Singh

      Hi Srilatha,

      What is the version of your Oracle Rightnow?

      Thanks,

      Gurinderpal

    • Mark Rhoads

      Also, load_curl() should only be available to "asynchronous" CPMs.

      Is the CPM script marked for "asynchronous execution"?

      Does this error occur when testing using "test" from the Process Designer?

       

    • Srilatha CK

      The version we have this issue is August 2012 and there no Asynchronous checkbox available. But on raising it with customer care they have confirmed saying CURL libraries are enabled.

    • Mark Rhoads

      Curl is only available to asynchronous CPMs in August 2013 or later.

       

    • Govindharaju Gurusamy

      Hi ,

      Am trying to invoke third party webservice using cURl in Rightnow. So far i have written below code and its working in Online PHP compiler but when i called from Rightnow it throws error like  " call to undefined function curl_init() ". Can any one tell me how can we solve this error. Is there any configuration we need?

      $body='<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
         <soapenv:Header/>
         <soapenv:Body>
            <web:GetCitiesByCountry>
               <!--Optional:-->
               <web:CountryName>India</web:CountryName>
            </web:GetCitiesByCountry>
         </soapenv:Body>
      </soapenv:Envelope>';

      $headers = array(
      'Content-Type: text/xml; charset="utf-8"',
      'Content-Length: '.strlen($body),
      'Accept: text/xml',
      'Cache-Control: no-cache',
      'Pragma: no-cache',
      'SOAPAction: "http://www.webserviceX.NET/GetCitiesByCountry"'
      );

          $URL = "http://www.webservicex.net/globalweather.asmx?WSDL";
          
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL,            $URL);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          $output = curl_exec($ch);
          print_r($output);   
          
          curl_close($ch);

       

      If you have any other sample code to consume third party webservice using cURL pls share with me.

       

      Thanks

      Govindh

    • Bipin Mittal

      Hi Govindh,

      Its mentioned in the comments already that you should use load_curl() function before calling other curl functions.

       

      ~Bipin

    • Govindharaju Gurusamy

      Hi Bipin,

      I did the same but i got same errror for below code

      Error : call to undefined function RightNow\CPMObjectEventHandlers\incident_update\curl_init()

          load_curl();
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL,            $URL);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          $output = curl_exec($ch);
          print_r($output);

       

      Is there any configuration we need for load_curl() method?

      Need to raise SR for this issue?

      Thanks

      Govindh

       

    • Mark Rhoads
    • Govindharaju Gurusamy

      Hi ,

      I have followed the document but we got same error( call to undefined load_curl() ) while we run the code. Is there any special configuration we have to do?

      Thanks

      Govindh

       

    • Mark Rhoads

      cURL is only available to asynchronous CPM Object Event Handlers in August 2013 or later.

      What release is your site on?

      Did you set the handler to be run asynchronously?