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

post external json into Dataobject


Go to End


4 Posts   1731 Views

Avatar
moloko_man

Community Member, 72 Posts

1 June 2012 at 6:08am

Is it possible to post external json data into either a DataObject or DataobjectSet in Silverstripe?

Basically I'm developing a small site that will be fed data from a mobile application. The iPhone/android app will push public data to the site. After the data is pushed I will be able to generate reports/graphs and have users search and compare themselves against other users.

I have looked into the RestfulService, and SOAPModelAccess and have been researching and searching the forums all day yesterday, but there is nothing that talks about being able to accept external post requests to an API on my server. Is this even possible?

Thanks

Avatar
Willr

Forum Moderator, 5523 Posts

2 June 2012 at 12:27pm

RestFul Service is the class for consuming remote API's (like twitter) RestfulServer is the class you want to look at for providing an API - http://API.silverstripe.org/2.4/sapphire/api/RestfulServer.html

Avatar
moloko_man

Community Member, 72 Posts

2 June 2012 at 8:13pm

@Willr, that does make more sense, thanks. I totally overlooked RestfulServer

I built a quick (and dirty?) test and its very simple. It's essentially a form posting, so in my controller I just set up an allowed actions for my method that will act as the form processor, set SecurityToken::disable(); so I don't get a CSFR attack notice, then just return what I need to do. (I'm doing this quick method to show proof of concept.)

I will use RestfulServer, though, to build out what I need so its more secure in the end.

Thanks again for your help.

Avatar
moloko_man

Community Member, 72 Posts

20 June 2012 at 10:38am

Does RestfulServer::authenticate() require that a user be present in the database? Or can I provide an API key for a device to connect to, to authenticate?