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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Cant get RestfulService to work with ->Request()


Go to End


7 Posts   2900 Views

Avatar
otherjohn

Community Member, 125 Posts

12 May 2010 at 9:34am

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

Community Member, 125 Posts

12 May 2010 at 9:44am

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

Community Member, 125 Posts

12 May 2010 at 10:11am

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

Avatar
biapar

Forum Moderator, 435 Posts

15 May 2010 at 12:22am

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

Avatar
jsirish

Community Member, 18 Posts

15 May 2010 at 10:31am

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

Community Member, 19 Posts

18 May 2010 at 9:53pm

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

Community Member, 11 Posts

12 August 2010 at 11:58am

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.