21475 Posts in 5781 Topics by 2620 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1063 Views |
-
API access and login

28 September 2010 at 4:19am
Hello,
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 (http://my.domain.com/Security/login...) before accessing the API? Any other solution?
I only receive an empty
<DataObjectSet totalSize="6"></DataObjectSet>
when I'm logged out. -
Re: API access and login

28 September 2010 at 4:28am Last edited: 28 September 2010 4:29am
Is this what you are after?
-
Re: API access and login

28 September 2010 at 5:03am
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(http://myurl.de/api/v1/MyObject/)
-
Re: API access and login

29 September 2010 at 4:11am
Solved...simply use
canView($member = null){
return true;
}Or do the curl-cookiejar way.
| 1063 Views | ||
|
Page:
1
|
Go to Top |


