K
K
Kirill Sirenko2015-08-14 12:59:45
PHP
Kirill Sirenko, 2015-08-14 12:59:45

Calling the service API. What is more correct?

Good afternoon!

I am implementing a form that, when sending data, accesses a third-party API (VoIP telephony service), in the first version I did this using curl in php, i.e. there was a scheme:
- form - sending data to ajax in a php script, - curl - response from the service in json - parsed, - we issue answers.
In the second version, I found the opportunity to implement the task directly in jquery, i.e. Now the call and the answer are right in the js file.

In this regard, questions:
1. This is the easiest in terms of structure, but is it more correct than the first option? Because:
- A security issue: in js, the secret key and login for accessing the API will glow, although I have already found how to close js from prying eyes - but still - is it safe?
2. How to get data from the database in a js file - the same logins and passwords and secret keys are stored differently in the database, because in different requests they change depending on what is selected in the initial form.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
evnuh, 2015-08-14
@evnuh

Well hello, head of the web studio.
Unfortunately, you will not be able to hide js, and with it private keys to the API.

V
Vitaly Inchin ☢, 2015-08-14
@In4in

I already found how to close js from prying eyes - but still - is it safe

Share this miracle of the 22nd century?
Such things are best done through puff and exclusively through it!
The maximum that can be entrusted to JS is Ajax requests to the script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question