User Tag List

Results 1 to 4 of 4

Thread: Retrieve articles from Wordpress site?

  1. #1
    Clicker Fusion 2.5Android Export ModuleiOS Export ModuleSWF Export Module
    leightonw87's Avatar
    Join Date
    Jan 2012
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Retrieve articles from Wordpress site?

    Not sure if in the correct place so move if necessary.

    I'm no expert when it comes to anything like this so really need help from someone who has managed o do it or similar, I need to be able to get a list of articles and download the selected article from the Wordpress site and break them up into an array, I've figured out how to do this bit somewhat using an ini file and the string parser, the main issue I have is loading a list of articles and loading selected article.

    I was told by people in discord about using prepared statements but I'm just confused by it all.

    I need this to work for Windows, iOS and Android os's.

    Any help on this be great as it's really holding me back, also the site is being made by someone else so don't know about how it will work.

  2. #2
    Clickteam Clickteam
    Danny's Avatar
    Join Date
    Aug 2007
    Location
    United Kingdom
    Posts
    3,016
    Mentioned
    21 Post(s)
    Tagged
    2 Thread(s)
    Is this for one site? (ie: your site?) if so, you could list the articles available in a standard ascii file and just GET that at the start of the frame and add it to a list...

    Your text file on the server that you would get can consist of article numbers like this:

    1#4#15#23#54#34

    and you can just delimit to then add your slugs and retrieve the data from the specified article...

  3. #3
    Clicker Fusion 2.5Android Export ModuleiOS Export ModuleSWF Export Module
    leightonw87's Avatar
    Join Date
    Jan 2012
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The site is a work in progress at the moment and I got no idea at the moment how the site will work, all I know is it will use wordpress. I'm such a newbie to this sort of thing and don't understand much of what you wrote apart from the string parser info. I'm going to have to swat up on wordpress and php I suppose...

    This is why I don't have my own proper site, don't have much time to work out how it all works and far too many distractions these days.

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Sep 2016
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make a php script that displays an article based on the id sent to it in the get request. Example: http:/example.com/myscript.php?article=1

    In the URL example you would have the PHP script set to grab the article with that ID.

    Here is a small PHP class I have not tested ( I just typed it into this forum window ) that would help you get started on pulling things from Wordpress. With this script you would then just send requests from Fusion with the id of the article in the GET request. Like http:/example.com/myscript.php?article=1 and then manipulate the returned text however you like.

    Code:
    <?php
    /*
        Create a database / database user (with proper permissions or all permissions) first and have the relevant information
    */
    
    class GetArticles
    {
        // Change this to the relevant values in your wp-config.php file
        private $db_host = 'localhost';
        private $db_user = 'database_username';
        private $db_pass = 'password';
        private $db_name = 'database_name';
    
        // This variable is used to interact with the database. Change classification to "protected" from "private" if extending class
        private $database;
    
        // This variable is used to provide the values from a $_GET request
        private $var;
    
        public function __construct() {
    
            // Connecting to the database and setting $var to $_GET
            $this->database = new mysqli( $this->db_host, $this->db_user, $this->db_pass, $this->db_name );
            $this->var = $_GET;
        }
        
        // Retrieves a single article. Option allowed for getting variable from function parameters or from $_GET. $_GET has priority
        public function single( $id=0 ) {
    
            // Set our $id based on if $_GET['article'] is set or not and make sure it is an integer
            $id = (int) ( $this->var['article'] ? $this->var['article'] : $id );
    
            // Select the post_content field from the wordpress database where the ID field matches the value of $id
            $select = $this->database->prepare( "SELECT post_content FROM wp_posts WHERE ID=?" );
            $select->bind_param('i', $id );
            $select->execute();
    
            if( $values = $select->get_result()->fetch_assoc() ) {
                return values['post_content'];
            }
        }
    }
    
    
    // Usage
    
    // If the URL has the "article" parameter (http://example.com/?article=2)
    if( isset( $_GET['article'] ) ) {
    
        // Instantiate the class on the variable $article
        $article = new GetArticles;
    
        // Echo the returned value from the method "single" inside the instantiated class in $article
        echo $article->single();
    }
    
    ?>

    Hope this helps you get started.

    Cheers

Similar Threads

  1. Retrieve text online from my web site for PC builds?
    By ducknet79 in forum Fusion 2.5
    Replies: 2
    Last Post: 15th May 2015, 11:30 PM
  2. Three Articles
    By Jacob in forum Articles
    Replies: 1
    Last Post: 12th August 2011, 06:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •