Results 1 to 8 of 8

 

Thread: Write up of what my site does and how to do it...

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Oct 2009
    Posts
    289
    Thanks
    49
    Thanked 17 Times in 16 Posts


    Hi,

    Thought I would do a bit of a write up of things I do with my site and how to go about doing it. Now some things am probably doing the wrong or slower way but thought this might help some newbies out.

    I will briefly explain the sort of things I have setup, then I will try and explain each one in detail (this is in no order, just random things I can think of).

    1. Tumblr blog, post to twitter and facebook automatically
    2. Create a Facebook fan page
    3. Read in the Voucher Code API from buy.at and affiliate window and display it in wordpress
    4. Import the medifusion game feed and turn it into posts in wordpress (including uploading and attaching the right image to the post)
    5. Import the Amazon Top 10 (Consoles in my case) and turn it into posts in wordpress
    6. Auto posting from wordpress to my facebook fan page
    7. Change a ECU into a nice looking auto scrolling unit

    Some of the above are via a plug-in and some I have written the PHP code for. If it's PHP then I use ShortCode Exec to display it in WordPress, hence why there is no opening and closing tags for the PHP.

    Will expand on each one but if there are any you would like me to do first, please say.

    Dave

  2. The Following 2 Users Say Thank You to theDaveB For This Useful Post:

    barneyboy (11-11-11), Dazza30 (13-11-11)

  3. #2
    Registered User

    Status
    Offline
    Join Date
    Jun 2008
    Posts
    124
    Thanks
    7
    Thanked 5 Times in 5 Posts
    Hi Dave,

    Would definitely be keen to see no 5. if it's simple php.

    Cheers

  4. #3
    Registered User

    Status
    Offline
    Join Date
    Oct 2009
    Posts
    289
    Thanks
    49
    Thanked 17 Times in 16 Posts
    Hi,

    Number 5. is a plug-in.

    http://feedwordpress.radgeek.com/

    Then for the feed, you just find what you want on the Amazon website and make a change to the URL to turn it into a RSS feed instead of a webpage.

    For instance -

    This is the top ten XBOX consoles on Amazon (I have left my tag on, so you know where to put it).

    PHP Code:
    http://www.amazon.co.uk/gp/bestsellers/videogames/676520011?tag=caniplay-21 
    Change the gp to rss -

    PHP Code:
    http://www.amazon.co.uk/rss/bestsellers/videogames/676520011?tag=caniplay-21 
    EDIT: Not all Amazon URL's are formatted like above but the ones that are, then this works.

    You can then use this new RSS url in the plugin and it will take each product and post it in WP. The beauty of the plug-in is each time it runs it updates posts if they already exists and creates posts for new products.

    Dave

  5. #4
    D4N
    Registered User

    Status
    Offline
    Join Date
    Nov 2011
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for that little write up, was explains and gives me more insight

  6. #5
    Dazza30's Avatar
    Registered User

    Status
    Online
    Join Date
    Mar 2006
    Location
    cheshire uk
    Posts
    1,161
    Thanks
    83
    Thanked 43 Times in 33 Posts
    Dave threads like this have become few and far between on this forum. I look forward to giving it a read once you've added more information

  7. #6
    Registered User

    Status
    Offline
    Join Date
    Oct 2009
    Posts
    289
    Thanks
    49
    Thanked 17 Times in 16 Posts
    1. Tumblr

    I use tumblr for posting bargains and anything interesting related to my website.

    Tumblr is so easy and quick to use, I love it for posting quick one liners with a link to my site. If I spot a bargain on another website, I goto the game on my site then share the link via Tumblr.

    Inside Tumblr you can link your FaceBook and Twitter accounts, so anything you post automatically goes to them as well.

    Not a lot of tutorial as such, as it's built into the Tumblr interface. I did knock up a bit of ASP code to read the Tumblr API and post it into a blog page on a clients site.

    This is the header part of the file. When Tumblr first came out, it was down more than it was up, so I wrote the code to save the XML to a blog.xml file locally, if the call fails it reads the local one etc...

    PHP Code:
    <%@ Page Language="VB" Debug="true" %>
    <%@ 
    Import Namespace="System" %>
    <%@ 
    Import Namespace="System.Xml" %>
    <%@ 
    Import Namespace="System.Xml.Linq" %>

    <
    script runat="server">


        
    Dim Posts As XElement

        Sub Page_Load
    (sender As ObjectAs EventArgs)

        Try
            
    'Read Tumblr Feed and save it locally
            '
    Put this in a try/catch as if it fails I want the page to carry on and use the local copy
            Dim xmlMasterUpdateDoc 
    As New XmlDocument()
            
    xmlMasterUpdateDoc.Load("http://liverpoolstudiohire.tumblr.com/api/read")
            
    xmlMasterUpdateDoc.Save("YOURHOSTINGSPACE\blog.xml")

        Catch 
    xmlEx As XmlException
            
    'Catch any XML error and display it.
            Response.Write("XML Exception Thrown -> " + xmlEx.Message)

        Catch eX As Exception
            '
    Catch the error and display it.
            
    Response.Write("Exception Thrown -> " eX.Message)
        
    Finally
            
    'Do the final cleanup such as closing the Database connection

        End Try

            If Cache("tumblrXE") is Nothing then

                '
    There is no tumblrXE item in the Cacheso load it from the local file
                Dim tumblrResponse 
    As XElement XElement.Load("YOURHOSTINGSPACE\blog.xml")

                
    Add it to the Cache and make it dependant on the local file (so it if changes the cache will)
                
    Cache.Insert("tumblrXE"tumblrResponse, New CacheDependency("YOURHOSTINGSPACE\blog.xml"))
            
    End If
            
    Posts Cache("tumblrXE").Element("posts")
        
    End Sub
    </script>
     
    This is the part of the file where you want to write the items to screen

    PHP Code:
    <%
    If 
    Posts.Attribute("total").Value <> "0" Then
        
    For Each itemElement As XElement In Posts.Elements("post")
    %>
              <!-- 
    post START here -->
            <
    div class="post">
    <%
        If 
    itemElement.Attribute("type") = "link" Then
    %>
              <
    h3><%=itemElement.Elements("link-text").Value%></h3>
              <
    div class="meta">
                <
    span class="category">Link</span>
                <
    span class="date"><%=itemElement.Attribute("date").Value%></span>
              </
    div>
              <
    p><a href="<%=itemElement.Elements("link-url").Value%>" Title="<%=itemElement.Elements("link-text").Value%>"><%=itemElement.Elements("link-text").Value%></a></p>
    <%
        
    End If
    %>

    <%
        If 
    itemElement.Attribute("type") = "photo" Then
    %>
              <
    div class="meta">
                <
    span class="category">Photo</span>
                <
    span class="date"><%=itemElement.Attribute("date").Value%></span>
              </
    div>
              <
    a href="<%=itemElement.Elements("photo-link-url").Value%>" class="img-load">
              <
    img src="<%=itemElement.Elements("photo-url").Value%>" alt="Photograph" width="150px" height="150px" />
              </
    a>
              <%=
    itemElement.Elements("photo-caption").Value%>

    <%
                If 
    Len(itemElement.Elements("photo-caption").Value) < 200 Then
    %>
                    <
    p>
    <%
                    For 
    1 to (200 Len(itemElement.Elements("photo-caption").Value))
                        
    Response.Write("&nbsp;")
                    
    Next
    %>
                    </
    p>
    <%
                
    End If
        
    End If
    %>

    <%
        If 
    itemElement.Attribute("type") = "regular" Then
    %>
              <
    h3><%=itemElement.Elements("regular-title").Value%></h3>
              <
    div class="meta">
                <
    span class="category">Regular</span>
                <
    span class="date"><%=itemElement.Attribute("date").Value%></span>
              </
    div>
              <%=
    itemElement.Elements("regular-body").Value%>
    <%
        
    End If
    %>
            </
    div>
            <!-- 
    post END here -->
    <%
        
    Next
    End 
    If
    %> 
    Ignore the fact is says PHP code, it's actually VB. This is possible in PHP but not bothered yet, if anyone wants in PHP I can re-write it.

    Forgot to mention, you can see the page in action here -

    http://www.liverpoolstudiohire.com/blog.aspx

    And the Tumblr blog is here -

    http://liverpoolstudiohire.tumblr.com/

    Dave

  8. #7
    Registered User

    Status
    Offline
    Join Date
    Oct 2009
    Posts
    289
    Thanks
    49
    Thanked 17 Times in 16 Posts
    4. Import the medifusion game feed and turn it into posts in wordpress (including uploading and attaching the right image to the post)

    I use this to add games that haven't been released yet into my WP site.

    For the PHP to run inside WP I use Shortcode Exec PHP plug-in.

    I created a shotcode called custom_post and put the code below into it (you can get rid of most of the echo commands, they are just so I know it's running). Then I have created a hidden page on my site and put this -

    Code:
    [custom_post url="http://game.find-services.co.uk/gameSearch.asp?site=YOURMEDIFUSIONTAG&platform=PC&releasefrom=01/08/2011&releaseto=31/08/2011&order=&page=1&pagesize=60&mode=heavy"]
    The XML that returns is all the game being released for the PC between the dates given.

    I then preview the page from the dashboard and that runs the code. I haven't worked out a way yet of getting the post into the right category, hence I write the category into the description. I then go through the posts, and put the game in the right category by looking what was written in the description.

    PHP Code:
    extract(shortcode_atts(array('url' => 'default'), $atts));
    require_once(
    'wp-admin/includes/media.php');
    require_once(
    'wp-admin/includes/file.php');
    require_once(
    'wp-admin/includes/image.php');
    echo 
    "Arg=" $url PHP_EOL;
    $xml simplexml_load_file(html_entity_decode($url));

    foreach (
    $xml->children() as $item)
    {


    // Create post object
    $my_post = array(
        
    'post_title' => $item->groupTitle ' on ' $item->platformName,
        
    'post_content' => $item->description 'Category: ' $item->category '[get_details ASIN="' $item->id '"]',
        
    'post_status' => 'draft',
        
    'post_author' => 1
    );

    // Insert the post and image into the database
    $new_post wp_insert_post$my_post );

    if(!empty(
    $item->imageURL))
    {
        
    $file_url media_sideload_image($item->imageURL,$new_post);
        echo 
    $new_post ' ' $item->imageURL ' ' $file_url;
    }
    else
    {
        echo 
    $new_post;
    }

    echo 
    '<br />';


    I have have another shortcode called [get_details] that is actually used in each post to show the price comparison for each ASIN, hence why it shows in the code above. If anyone wants the code for that, let me know.

    Think that's about it. I wrote this as it was taking me ages to add games to the site and thought there must be a quicker and easier way. I use to have a ASP site that was fully automated and run live from the XML but couldn't get it ranking in Google, changed to WP and it ranks much better.

    Old site was Can i Play ? - for all your gaming needs | Xbox 360 | PS3 | Wii | PSP | DS | DSi | PC | Bargains | Articles if your interested.

    Dave

  9. #8
    Registered User

    Status
    Offline
    Join Date
    Oct 2009
    Posts
    289
    Thanks
    49
    Thanked 17 Times in 16 Posts
    No 3. Read in voucher code feeds from both buy.at and affiliate window.

    These routines read the feed in from your account for merchants that have accepted you. I have removed stuff from the URL that is specific to my accounts.

    This is for Affiliate Window and uses CSV format.

    PHP Code:
    $file_handle fopen("http://www.affiliatewindow.com/affiliates/discount_vouchers.php?user=?????&password=BIGLONGPASSWORDHERE&export=csv&voucherSearch=1&rel=1""r");
    echo 
    '<table>';
    echo 
    '<tr>
            <th scope="col">Retailer</th>
                <th scope="col">Description</th>
                <th scope="col">Voucher Code</th>
                <th scope="col">Start Date</th>
                <th scope="col">End Date</th>
                <th scope="col">Link</th>
            </tr>'
    ;

    while (!
    feof($file_handle) ) {

        
    $line_of_text fgetcsv($file_handle);

        echo 
    '<tr><td>' $line_of_text[0] . "</td>";
        echo 
    '<td>' $line_of_text[3] . "</td>";
        echo 
    '<td>' $line_of_text[2] . "</td>";
        echo 
    '<td>' $line_of_text[5] . "</td>";
        echo 
    '<td>' $line_of_text[6] . "</td>";
        echo 
    '<td><a href="' $line_of_text[4] . '" target="_blank" rel="nofollow" title="Visit website to use voucher code">Use Code</a></td></tr>';

    }

    fclose($file_handle);
    echo 
    '</table>'
    Buy.at XML feed (this is a bit redundant, since everything is moving to AW).

    PHP Code:
    $xml simplexml_load_file("https://users.buy.at/ma/index.php/affiliateVoucherCodes/list?handle=0&filter_status=y&include_pending=1&include_active=1&include_expired=0&prog_id=0&vertical_id=0&orderby=date_added&dir=desc&format=xml&email=YOUREMAILADDRESS&password=BIGLONGPASSWORDHERE");

    echo 
    '<table>';

    echo 
    '<tr>
                <th scope="col">Retailer</th>
                <th scope="col">Description</th>
                <th scope="col">Voucher Code</th>
                <th scope="col">Start Date</th>
                <th scope="col">End Date</th>
                <th scope="col">Link</th>
            </tr>'
    ;

    foreach(
    $xml->body->children() as $child)
    {
            if(
    $child->status=='Active')
            {
                echo 
    '<tr>';
                echo 
    '<td>' $child->programme "</td>";
                echo 
    '<td>' $child->description "</td>";
                echo 
    '<td>' $child->offer_code "</td>";
                echo 
    '<td>' $child->start "</td>";
                echo 
    '<td>' $child->end "</td>";
                echo 
    '<td><a href="' $child->url '" target="_blank" rel="nofollow" title="Visit website to use voucher code">Use Code</a></td>';
                echo 
    '</tr>';
            }
    }

    echo 
    '</table>'
    The AW php routine needs work, as pound signs don't display properly and could do with skipping the first and last record in the file.

    Dave



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Content Relevant URLs by vBSEO 3.5.0 RC2