Hi,pleasure to meet you all.I wanna to ask how to write a javascript code to connect with php api authentication located at my server(eg. www.mydomain.com/api/index.php).

1.I wanna put a javascript code to call the api authentication function at my website server so that other people can access through the api key provide by my website.
eg location script www.mydomain.com/api/script/access.js

2.the access.js will call to my server's api(www.mydomain.com/api/index.php),do the authenticate api process and return the result back to client side(if not valid api key,don't allow return result data to the client side.

3.so, how do i write the javascript code to put at www.mydomain.com/api/script/access.js(this script need to call the api key authentication class that located at my server)?is that i can use the cookies of the client side to detect again the user data when the user next time access the access.js?

4. how to i write the api key authentication class at my www.mydomain.com/api/index.php so that only valid api key user can access the result data?

Note:www.mydomain.com/api/script/access.js can be access through embeded into html format like this

<script src="www.mydomain.com/api/script/access.js?key=ADD_YOUR_KEY_HERE" type="text/javascript"></script>

Note:Kindly give simple code so that i can more understandable on the flow.
Note:thanks for all guys help solve my problem!!!:)

5 Years
Discussion Span
Last Post by Stefano Mtangoo

Is that only can do using ajax way? i m sorry to say that i havnt create any api communication between php and javascript before!what i want is create a js scipt(this scipt can be access by other web site developer with valid api key) to communicate with the php file to let authenticate user retrieve/create/update the data to the database through the script .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.