How to script 360 degrees view with camera using mobile gyro / accelerometer ?

Hey all,

I know this is an advanced stuff, but I need to script a 360 degrees free view for the user
while he is moving his device:
when the user look up the camera will move up (show the sky)
when the user look down → the ground
as well as for the right and left;

very much similar to this video:
https://www.youtube.com/watch?v=XN8x9sUHSC4
at sec. 55

Any ideas guys?
thanks.

please give me any leads. this is important.