Pick up internal website form content (POST)

Asked

Viewed 133 times

0

Hello. I would appreciate it if someone could give me a hand, a way to solve this problem.

Programming language: PHP.

Problem: I want to work with information from a website. This information is in the HTML of the page of the site which I will consult every day treat this html, via php, and save the information I want in the database of the application I am creating.

The problem is in passing to the site the parameter I want for it to upload the information I want. What I don’t know is how to pass a parameter via POST.

The website is the https://secure.tibia.com/community/? subtopic=killstatistics. I need to pass the World and save the entire html of the page in a variable. The fact of saving the html of the page and treating it, I already know.

The problem is how to pass the world parameter to the link and it click as if I had chosen World on the page and clicked on the Submit button?

1 answer

0


If you create a file index.php and paste that content inside and run, the tibia page will appear. Until then ok, but if you go to the Google Inspector and go to the console a message will appear...

Copy the code, run and view on your console

<?php
ini_set("display_errors", true);


$init = curl_init();

curl_setopt_array($init, [
  CURLOPT_URL => "https://secure.tibia.com/community/?subtopic=killstatistics",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POSTFIELDS => http_build_query(["world"=>"antica"]),
  CURLOPT_SSL_VERIFYHOST => false,
  CURLOPT_SSL_VERIFYPEER => false
]);
$r     = curl_exec($init);
$close = curl_close($init);

echo $r;

This is the message, note the blank message.

inserir a descrição da imagem aqui

For those who have used the Google Developer Console know that when you will use a Google application, that in my case I used a OAuth Token, they ask you to put a redirect address that after the user enters your google account and authenticate, Google will redirect to your web page and pass the token via ?token=blabla query get. I think facebook is happening the same thing, never used, but probably that’s it.

In short You would have to have access to the API that the owner created there on facebook.

In case facebook will only accept requests from https://secure.tibia.com/ but we are using http://localhost, got it ?

  • Got it! Thank you, Marcelo!

Browser other questions tagged

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