• Hi
    I don’t know if this is the right place to post this..if not, I’m sure an admin can move it to the right place…
    Anyway…..
    I had been having some trouble getting Kung-Tunes to display the last played songs in iTunes on my blog.
    Ian Darlington at https://www.the-way-to-the-centre.org.uk/blog/ read about the problems I was having, and were so extremely kind to sit down and write me a complete tutorial.
    I followed his tutorial step-by-step and everything went smooth..no problems at all…so in agreement with Ian I decided to post the tutorial here! Hopefully it can help a lot of newbies…like me ??
    Tutorial:
    1. Get kung-tunes to upload files – you need to set it up to transfer
    to the root wp folder. For me the settings are:
    Upload method: ftp
    URL – https://ftp.the-way-to-the-centre.org.uk (my normal ftp path)
    Proxy – field blank
    File path – not needed for ftp (I think), mine is set to a local folder
    on iBook
    name – trackinfo.txt
    FTP settings
    Directory – /wordpress/ (the path to my wp root folder)
    username – my ftp username
    password – my ftp password
    Only the use PASV-mode for file transfer box is ticked. (I think this
    is the default)
    2. If you get this all right, you should then be able to get
    trackinfo.txt into your wp root when you click the upload now button.
    3. For the formatting of the list on my blog I used:
    ^t#a #a#p [
    target="_blank">^p]#p
    for the current and recent tracks. But see
    what you can do, it was a bit of trial and error for me.
    4. Getting the tracklisting onto your blog.
    There is a plugin – copy the following and save as something like
    myitunes.php (you might want to check for any whitespaces, this caused
    trouble for me).
    <?php
    /*
    Plugin Name: My iTunes
    Plugin URI: https://chrisjdavis.org/index/category/wp-hacks/
    Description: A plugin that parses the text file created by Kung-Tunes
    and displays it on your site.
    Author: Chris J. Davis
    Author URI: https://chrisjdavis.org/
    */
    function display_tunes() {
    $fp=fopen("trackinfo.txt","r");
    $track=fgets($fp,1024);
    echo "$track";
    fclose($fp);
    }
    ?>

    5. upload it into your plugins folder and active.
    6. Use <?php display_tunes() ?> in your index where you want the
    listing to appear.
    All credits to Ian Darlington….(and Chris J Davis for the plugin)
    Kind regards
    Madsen

Viewing 3 replies - 1 through 3 (of 3 total)
  • Madsen

    I have been trying to apply your suggestions to make kungtunes work on a WP site. I have included the suggested line in index.php buy get the following message on the site where I want the tune deatil to appear:

    Warning: fopen(trackinfo.txt): failed to open stream: No such file or directory in /home/sftiocom/public_html/wp-content/plugins/myitunes.php on line 15

    Warning: fgets(): supplied argument is not a valid stream resource in /home/sftiocom/public_html/wp-content/plugins/myitunes.php on line 16

    Warning: fclose(): supplied argument is not a valid stream resource in /home/sftiocom/public_html/wp-content/plugins/myitunes.php on line 18

    Any suggestions how I get around this?

    GJ
    Melbourne Australia

    Hey, GJ, I think I might be able to help. I had the same problem for a couple of days, but I just came across a fix, and I think it might work for you.

    Here’s the problem: the trackinfo.txt file is in the root of the wordpress directory, and for some reason, wordpress doesn’t like that. It won’t allow the file to be accessed. If you try to view the file in your browser, rather than requesting it in a php script, it just takes you to your homepage. So, the fix is this: make a folder (I called mine “kung,” but you can do whatever makes sense to you) in your wordpress/wp-content/plugins/ folder, and tell Kung to put the file there, rather than your root directory. Now you just have to edit the path for “fopen” in your PHP file.

    Here’s how I do mine

    <?php
    /*
    Plugin Name: My iTunes
    Plugin URI: https://chrisjdavis.org/index/category/wp-hacks/
    Description: A plugin that parses the text file created by Kung-Tunes
    and displays it on your site.
    Author: Chris J. Davis
    Author URI: https://chrisjdavis.org/
    */
    function display_tunes() {
    $fp=fopen(“https://s90251085.onlinehome.su/Fagatrodle/wp-content/plugins/kung/trackinfo.txt&#8221;,”r”);
    $track=fgets($fp,1024);
    echo “$track”;
    fclose($fp);
    }
    ?>

    You should probably use an absolute path, like I did, just to be on the safe side.

    The function doesn’t change, so you still type “<?php display_tunes() ?>” wherever you want it. I have it in my sidebar, right above the meta functions.

    I use Gerpok personally to display what I’m listening to on my blog (at the top).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Tutorial: Currently playing song – \"Kung-Tunes\"’ is closed to new replies.