Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Cant get RestfulService to work with ->Request()


Reply

7 Posts   1669 Views

Avatar
otherjohn

12 May 2010 at 9:34am Community Member, 125 Posts

Hi all, Since RestfulService::Connect has been depreciated, can someone point out what I am doing wrong here?

Here is my code, I get no response. But when I used ->Connect() instead of ->Request(), it worked.
Can someone point out what I am missing?
The $url = a twitter user feed.

function doCall($url = null, $requireAuth = false,$params = null){
      try{
         
         $twitter = new RestfulService( $url );
         
         
         if($params)
            $twitter->setQueryString($params);
         
         $conn = $twitter->request();
         
         $xml = @simplexml_load_string($conn);
         
      
         if($xml == false){
            return false;
         }else{ return $xml;}
      }
      catch(Exception $e){
         
         return false;
      }
   }

Avatar
otherjohn

12 May 2010 at 9:44am Community Member, 125 Posts

This line is not returning anything?
         $xml = @simplexml_load_string($conn);
Any Idea? It seems that $conn returns from -->Request as an obj and not a string.

Avatar
otherjohn

12 May 2010 at 10:11am Community Member, 125 Posts

adding $conn = $conn->simpleXML(); seems to fix it.

Avatar
biapar

15 May 2010 at 12:22am Forum Moderator, 435 Posts

if there is'nt a RestFull service, How is possible to communicate with SS from remote service?

Avatar
Dynamic

15 May 2010 at 10:31am Community Member, 16 Posts

Hi otherjohn,

Running into the same problem, trying out 2.4 stable and modifying the old Twitter module.

adding "$conn = $conn->simpleXML();" didn't do it for me, the "$xml = @simplexml_load_string($conn);" still returns nothing.

Could you repost your final code? Hoping I can figure something out for this.

Thanks!

Avatar
ram

18 May 2010 at 9:53pm Community Member, 19 Posts

Hi

SS 2.4.0 Since RestfulService::Connect has been depreciated, so we replace to ->request('')->getBody();

eg.,
      $newsdet = new RestfulService($url,"3600");
      $conn = $newsdet->request('')->getBody();
      $msgs = $newsdet->getValues($conn);

Hope its works

Regards,
Ram
http://www.agriya.com,http://www.rayzz.net, http://www.anova.tv, http://www.isocial.in, http://www.markit.me

Avatar
dayer

12 August 2010 at 11:58am Community Member, 11 Posts

Hi,

but if I need obtain values and attributes, have I to use getValues and getAttributes? Because by the moment I have to use simplexml_load_string and after create a DataObjectSet and fill it with a values and attributes array.

Regards.