Jump to content

Get forum data from remote site


David Norgren
 Share

Recommended Posts

I'm looking to fetch data from the forums (using SQL commands) and use the data on a separate site (that isn't related to IP.Board). An example of such data is latest topics in a specific forum, or the topics with the most reputation.

 

What would be the best way to achieve this? Basically I want to create a new page that contains the result of the SQL command, and fetch that page using Ajax (with Access-Control-Allow-Origin).

Link to comment
Share on other sites

More precisely, you want to sync to seperate forums.

May I ask why? Google HATES duplicate content and one or the other website will be punished for it.

 

Unless you mean for statistical purposes, you could just create a php file that pulls data from the database and outputs it as JSON, from there your server can grab it, and work with the data using json_decode(file_get_contents("http://ipb.mysite.com/json/topics.php?output=json"), true);

If so and you're wanting someone to do it for you, send me a PM and we can work something out.

Edited by RADStudios
Link to comment
Share on other sites

59 minutes ago, RADStudios said:

you could just create a php file that pulls data from the database and outputs it as JSON

This is the part I'm wondering how to accomplish. The site that wants the data is not a forum and has nothing to do with IP.Board.

What's the PHP required to A. Connect to the forum database, B. Perform the query and C. Print the result as Json?

Link to comment
Share on other sites

Hey David,

http://php.net/manual/en/book.mysqli.php
http://php.net/json_encode
http://php.net/json_decode
http://php.net/file_get_contents
http://php.net/header

header('Content-type: application/json');
$Sql = new MySQLi("localhost", "username", "password", "database_name");
$st = $Sql->query("SELECT * FROM forums_topics ORDER BY tid DESC LIMIT 200");
echo json_encode($st->fetch_all(MYSQLI_ASSOC));

 

Link to comment
Share on other sites

4 minutes ago, Stuart Silvester said:

If you're on 3.4, you could use external blocks in IP.Content, if you're using IPS4, IPS4.1 will bring back external block functionality.

Hey Stu, would this allow raw json output?

Ah, I assume only if suite wrapper is disabled.

Edited by RADStudios
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...