David Norgren Posted October 3, 2015 Posted October 3, 2015 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).
VizionDev Posted October 3, 2015 Posted October 3, 2015 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.
David Norgren Posted October 3, 2015 Author Posted October 3, 2015 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?
VizionDev Posted October 3, 2015 Posted October 3, 2015 Hey David, http://php.net/manual/en/book.mysqli.phphttp://php.net/json_encodehttp://php.net/json_decodehttp://php.net/file_get_contentshttp://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));
David Norgren Posted October 3, 2015 Author Posted October 3, 2015 9 minutes ago, RADStudios said: Hey David, If it's that simple, then I guess my question is where I find the database information (name/username/password)?
VizionDev Posted October 3, 2015 Posted October 3, 2015 Your host / provider. If you're on the IPS Cloud Community, You don't have access to this.
David Norgren Posted October 3, 2015 Author Posted October 3, 2015 3 minutes ago, RADStudios said: Your host / provider. If you're on the IPS Cloud Community, You don't have access to this. So I can't access the database I'm paying for? Or do I have to get support?
VizionDev Posted October 3, 2015 Posted October 3, 2015 No they do not allow direct access to the MySQL Database. (I've asked)
David Norgren Posted October 3, 2015 Author Posted October 3, 2015 Thanks. I will look into the self-hosting plans. They seem to be cheaper anyway.
Stuart Silvester Posted October 3, 2015 Posted October 3, 2015 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.
VizionDev Posted October 3, 2015 Posted October 3, 2015 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.
Stuart Silvester Posted October 3, 2015 Posted October 3, 2015 9 minutes ago, RADStudios said: Hey Stu, would this allow raw json output? Ah, I assume only if suite wrapper is disabled. Not greatly, Pages gives you some JavaScript/code that you put on the page, it takes care of the rest.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.