php - Request data from Laravel API into wordpress -


i working on project on laravel 5.1, , want make restful api later can use same code , request data mobile apps or other websites. project in initial stages , want make correct right beginning.

suppose have simple route calling dashboard method on admincontroller. after logging in redirects admin dashboard page data.

/******************** laravel project ***********************/         //routes.php             route::group(['middleware' => 'auth'], function () {                 route::get('dashboard', 'admincontroller@dashboard');             });         // admincontroller         public function index(){             $data = 'some data';             return view( 'superadmin.dashboard')->with('data', $data );         } 

now want same data in wordpress project. how use api fetch data variable (without view) ? dont want create method that, there way can use same function fetch data json?

i read in forum can access data rest this. not working.

http://admin:admin123@example.dev/dashboard

as appreciate :)

personally, create application api. in case laravel application.

then i'd make http requests api wordpress, or mobile application.

i find returning json api easier work with. laravel makes easy:

return response::json(array(     'username' => 'superadmin',     'role' => 'admin',     'friends' => array(       '2345',       '884'     ) )); 

also, don't send username , password that. http auth insecure. http://adrianotto.com/2013/02/why-http-basic-auth-is-bad/

i tend use oauth secure apis.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -