How do I share information from my site with another?

0

I have 2 sites, the first that has the information and the second that wants to get this information, which in this case would be a kind of articles.

Articles contain title, image, description, tags, publication date, author information (name, user name, profile image) and various other fields.

My question is how can I share this information securely and that only my second website can have access? In PHP, Javascript / jQuery

Issue

Note: I would like to just get the data, something like json

Example:

[
    {
        "title": "Título do artigo",
        "image": "http://...."
        ......
     },
     {
        "title": "Título do artigo 2",
        "image": "http://...."
        ......
     }
]
    
asked by anonymous 21.10.2017 / 23:38

2 answers

1

If the 2nd site is a single page uses in php uses type:

<form action="Para o 2°Site.php" method="POST">

<p></p>Login:<input type="text" name="Login"></p>
<p>Senha:<input type="password" name="Senha"></p>

<p><input type="submit" align="center" value="Entrar"> | <input type="reset" value="Limpar"></p>


</form>

And on the other site uses a php to receive:

<?php

$Login = $_POST["Login"];
$Senha = $_POST["Senha"];

print "Bem Vindo ".$Login;

?>

Just set up the code and implement in your 2 sites what goes in the site that will send and the number 2 that will receive.

If it is more than 1 page, I'm not sure how it's done.

And try to change action="Para o 2°Site.php" to .html if your 2nd site is in html.

    
21.10.2017 / 23:48
0

Yes, you need one site / server to generate the information, and another to read the response. (I think I understood the purpose).

If it is, you would have to create requests, for a GET on the other server, it returns you a JSON. To limit access we would use .htaccess, as a constraint for different IP connections. I do not know if SERVER to SERVER would work, just like client use, but it can be a simple alternative. (There are several ways to create a TOKEN security pattern as well as common webservices.)

In practice: The generation of data would have to have its trigger, in this case a GET request. www.yourdomain.com/suaURLnaoAmigavel.php?gatilho=SEUS_PARAMETROS

if(isset($_GET['gatilho'])){ 
     $abc = array();
     $abc[]['title']=$valor;
     $abc[]['image']=$valor2;
     echo json_encode($abc).
}

In the end, I would use the PHP function json_encode($abc) ;

Output example:

 [
{
    "title": "Título do artigo",
    "image": "http://...."
    ......
 },
 {
    "title": "Título do artigo 2",
    "image": "http://...."
    ......
 }
 ]

Now let's go to JQuery, with the answer processing.

$.ajax({
   url:'www.seuservidor.com/suaURLnaoAmigavel.php?gatilho=SEUS_PARAMETROS',
   cache:false,
   method:'GET',       
   success:function(d){
     d=JSON.stringify(eval("(" + d + ")"));
     d=(JSON.parse(d));
     for(var inf=0;inf<=d.length;inf++){
         $('#ondevcquiser').append(d[inf]['title']);
     }
   }
});

Remembering that I just gave you the very generic code, you'll have to work on it if it really helped you.

Good luck, I hope I have helped you!

    
22.10.2017 / 04:29