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

    • Govindharaju Gurusamy

      Hi ,

      I have raised SR to oracle support and they were enabled curl_init api in rightnow server. Now i can call the third party wsdl file but i got soap xml response for my input request. How to get the value or how to extract the value from soap xml response using RNCPHP.

      Please share me if you have any snippet for that.

      Thanks

      Govindh

    • Ben Johns

      The \load_curl() function can cause intermittent issues when called inside an async CPM: http://cxdeveloper.com/article/curl-and-async-cpms

      It should be called inside a conditional, like this:

      if (!function_exists("\curl_init"))
      {
          \load_curl();
      }
      
    • jayarami reddy

      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  " Empty Results ". Can any one tell me how can we solve this error. Is there any configuration we need?

       

      <?php
      /*
       * CPMObjectEventHandler: create_incident
       * Package: RN
       * Objects: Incident
       * Actions: soap request
       * Purpose: soap response
       * Version: 1.2
       */

      use \RightNow\Connect\v1_2 as RNCPHP;
      use \RightNow\CPM\v1 as RNCPM;

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

    • Erica (Leep) Anderson

      Thanks for adding your question, Jayarami. It's great to have new folks join the Community and asking questions! smiley

      I did want to take this opportunity to provide a friendly reminder to everyone about an on-line community best practice. If you have a question that is related to an existing discussion (but not the same question), it's better to post a new discussion thread, because:
      • Helps a discussion thread stay focused on the original topic...it's easier for people to respond to questions and it's easier to follow the discussion (rather than have comments on multiple conversations happening within a single thread)
      • Each question can have its own a "best answer" marked.
      • Creates reusable content by having the questions discussed obvious in the title of the discussion thread. 
      For future reference, can you please start a new discussion thread for your question, even if it is related to this discussion thread? To start a new thread, you want to go to either the "User Discussion Forum" and "Developer Discussion Forum" and then pick the most relevant forum board for your question and then look for "New Topic" on the right hand side (see attached screenshot).
       
      Thanks, and keep those questions coming!
       
      Best,
      Erica, Community Manager
    • Ruhul Amin

      Hi,

           My RightNow version is Feb 2015 and getting curl_init error.

      So tried using load_curl() and \load_curl(); like below

      \load_curl();
      $curl = curl_init();

      But every time having same error "Fatal error: Call to undefined function load_curl()"

      Anyway,

      How to run custom script in "asynchronous " mode. or  what does it mean "Is the CPM script marked for "asynchronous execution"?" ?

      Please provide a bit explanation or code exmaple

      Thanks a lot.

      Ruhul

    • Pramod Vasudeva Murthy

      Ruhul,

      I think you need to search for existing posts first which relates to your question and then comment on existing ones. As it is a standard practice of community, to create a new question for your query.

      Only if your comment supports the existing discussion then it makes sense to make your mark or else you need to adhere to guidelines.

      And coming to your question - You need to execute CPM asynchronously so you need to check the checkbox while uploading your code.

      PFA Sample code.

      - VIP

    • Ruhul Amin

      Hi Pramod,

       I searched for the same problem and found this( if I didn't search for the existing one then how I found this?? ) for that reason I posted my problem here.

      Sorry, overlooked @eleep's comment earlier. I should post my question as a new thread. Here is the link

      http://communities.rightnow.com/posts/3f4aa1a954

      My custom script will not run as CPM but will be called on a button press in a "Browser Control". Please follow the new post in the above link to post your comment.

      Thanks.

      Ruhul