I have 2 sites. Let's call it :
A
B
Website B
have a nice list of data, and all of its relation.
I want to allow website A
to access website B
and load those data
.
Of course, Website
A
will need some kind of credentials, api_keys, or password to access into websiteB
. Right ? I never done this.Then after the credential match, website
B
will return the data back to websiteA
as json file.Then, website
A
will receive that json file, and load them into HTML and display it.
I hope I am clear enough regarding what my goal is.
Here is what I've tried :
After doing some researches, I came across this site. I really liked it. I finished it all way.Now, I kind of get a sense of RESTful API a little more.
Now, moving on to code
In my filters.php
I modify
Route::filter('auth.basic', function()
{
return Auth::basic("username");
});
In my routes.php
Route::get('/authtest', array('before' => 'auth.basic', function(){
return return "It's work !";
}));
After, I run
Note
-
username
=firstuser
-
password
=first_password
C:\wamp\www\laravel-1
λ curl --user firstuser:first_password localhost/l4api/public/index.php/authtest
I see
It's work !
As of right now, it only return a string.
- How do I do it if I want to return the whole users table in json format ?
-
So far, I have not use any
api_key
at all ? Is that bad ?Big
thanks
to everyone who involve in this post.