N
N
Nikolay2017-03-28 18:51:37
PHP
Nikolay, 2017-03-28 18:51:37

How to organize the work of the script on another resource?

Hello!

There is a small service that has a calculator.

You need to somehow allow users to install this calculator on the site.
But that they could do this only after registering, and having received a certain code for a certain site.

Tell me, maybe there are ready-made solutions, or in which direction to dig? I haven’t come across this at all before, I don’t even know where to start ;(

Thank you in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2017-03-28
@sergiks

You can make a calculator in JS so that it sends requests to your server and receives the result of the calculation in response. In this case, to fulfill a cross-domain request from your server, you will need to send the "Access-Control-Allow-Origin" header indicating the domain from which the request came, otherwise the client browser will not show it - cross-domain request security policy. And you benefit - you can collect query statistics.
That. when registering, you will give the client a code with some kind of key, which on your server can be unambiguously converted into one of the registered domains. And if there is one, you will return "Access-Control-Allow-Origin: tot_domen.tld" in the response headers

E
Eugene, 2017-03-28
@e_snegirev

Well, here is the solution, as already mentioned above. When registering a user, ask for his website, solve it in the system, write a js script and send requests from it to your server, granting permission to the specific domain from which the request is coming. In short: js calculator script and php api.
You can try just an iframe, but this will probably be some kind of mockery

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question