• Hi,

    I’m in need of help!

    I have created a wordpres widget that consumes a webservice, however when I upload this it doesn’t display the data. If another widget is added to the side bar below it it wont render, because the code seems to bomb out.

    I have no error message so finding it very hard to understand what is wrong.

    Before wrapping it in the relevant function to call in wordpress I tested the code and it runs perfectly and retunrs the relevent data.

    Can any one help me at all?

Viewing 3 replies - 1 through 3 (of 3 total)
  • your widget sounds very hungry…..

    links to see the problem would be helpful. or code examples (in a pastebin if large)

    Thread Starter kirbkrawler

    (@kirbkrawler)

    <?php
    /*
    Plugin Name: Customer Review Webservice
    Plugin URI: https://www.test.com/
    Description: Widget to take the latest 5 reviews
    Author: KirbKrawler
    Version: 1
    Author URI: https://www.test.com/
    */
    
    function GetCustomerFeedback()
    {
       // echo "Customer Reviews";
    ini_set("soap.wsdl_cache_enabled", "0");
    
    $client = new SoapClient('https://XXXXXXXX?wsdl');
    
    print_r($client);
    
    $xml = $client->GetCustomerReviewsTable();
    
        //echo "xml";
    
    $result = $xml->GetCustomerReviewsTableResult;
    
    //print_r($result);
        //echo "results";
    
    //
    $x = simplexml_load_string((string)$result);
    
    foreach($x->tr as $item)
            {
    
               echo "<table>";
               echo "<tr><td>".$item->td[3]." ".$item->td[0]."</td></tr>";
               echo "<br /><br />";
               echo "<tr><td>Need to find the service type</td></tr>";
               echo "<br/><br/>";
               echo "<tr><td>".$item->td[4]."</td></tr>";
               echo "<tr><td>".$item->td[5]." Depot Average Rating ".$item->td[6]." out of 5</td></tr>";
               echo "<br/><br/>";
               echo "<tr><td>Review Date: ".$item->td[1]."</td><tr>";
               echo "</table>";
            }
    }
    
    function widget_GetCustomerFeedback($args) {
      extract($args);
      echo $before_widget;
      echo $before_title;?>Top 5 Customer Reviews<?php echo $after_title;
      GetCustomerFeedback();
      echo $after_widget;
    }
    
    function GetCustomerFeedback_init()
    {
      register_sidebar_widget(__('Customer Review Webservice'), 'widget_GetCustomerFeedback');
    }
    
    add_action("plugins_loaded", "GetCustomerFeedback_init");
    ?>

    Thanks Voodoo, your help is much appreciated.

    Thread Starter kirbkrawler

    (@kirbkrawler)

    Sorry I made a mistake in the title, meant to say want a widget to consume a webservice.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress widget consuming a widget’ is closed to new replies.