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

API access and login


5 Posts   1272 Views


28 September 2010 at 4:19am Community Member, 88 Posts


I'd like to use the Restful API for one of my Objects. It works all great when I login with the browser. But how do I login using a HTTP GET with Silverstripe? Do I have to use curl to make a POST on the login form ( before accessing the API? Any other solution?

I only receive an empty

<DataObjectSet totalSize="6"></DataObjectSet>

when I'm logged out.


28 September 2010 at 4:28am (Last edited: 28 September 2010 4:29am), Forum Moderator, 1796 Posts

Is this what you are after?


28 September 2010 at 5:03am Community Member, 88 Posts

Well, not really. Your solution works in a browser, because it accepts Session/Cookie data. But when you try that with file_get_contents(), it will fail because of the redirect after a successful login. Therefore it will be neccessary to use curl to survive the redirect and remember Session/Cookie data.

I'm interested in a solution that allows the use of file_get_contents(


28 September 2010 at 11:37pm Community Member, 88 Posts

Is there a way to use the api without login?


29 September 2010 at 4:11am Community Member, 88 Posts

Solved...simply use

canView($member = null){
return true;

Or do the curl-cookiejar way.