How do I share information on my website with others?

Asked

Viewed 59 times

0

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

Articles contain title, image, description, tags, date of publication, author information (name, username, profile image) and several other fields.

My question is how can I share this information securely and only this second site of mine can be accessed? In PHP, Javascript/jQuery

Editing

Note: I would like to take only the data, something like json

Example:

[
    {
        "title": "Título do artigo",
        "image": "http://...."
        ......
     },
     {
        "title": "Título do artigo 2",
        "image": "http://...."
        ......
     }
]
  • in fact whether to share the database?

  • No, I only want limited information about the articles securely in which only the second site can access

  • You can do an XML feed on one site and pull the information on the other.

2 answers

1

If the 2°site is a single page use in php 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 pack the code and implement in your 2 sites will the site that will send and the 2 that will receive.

If it’s more than 1 page I’m not sure how to do it.

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

  • 1

    One of us doesn’t understand the question.. I think your interpretation is wrong...

  • 1

    ata now understood that he wants to make my answer this wrong so I thought he wanted to send like a login form or something like.

  • Nevertheless, thank you very much for your reply :)

0

Yes, you need a site/server to generate the information, and another to read the answer. (I think I understand the purpose).

If so, you would have to create requests, for a GET on the other server, it returns a JSON. To limit access we would use . htaccess as a limiter for separate IP connections. I don’t know if it would work SERVER to SERVER, just like using the client, but it can be a simple alternative. (There are several ways to create a TOKEN security standard as well as common webservices).

In practice: Data generation would have to have its trigger, in case a GET request. www.your.com/yourURLnaoAmigavel.php? trigger=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 only gave you the very generic code, you’ll have to work on it if it really helped you.

Good luck, I hope I helped you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.