Showing posts with label blog. Show all posts
Showing posts with label blog. Show all posts

Monday, 14 May 2018

Get blogspot content using JavaScript fetch

This example pulls in JSON data from a blog hosted on

First, I'll need to get fetch.
To add it to your project, change to your project directory:
cd myApp
Then use the following command:
npm install node-fetch --save

const fetch = require('node-fetch');
const url = '';
var myFetch = fetch(url);

myFetch.then(response => response.json()).then(function(data) {
  console.log('Caught an error ',err);

function showMyData(md) {
  md.feed.entry.forEach((e) => {
    var title = (e.title.$t || '');
var url = ( || []).pop().href;
    var date = new Date(e.updated.$t ||;
    var lessLines = e.content.$t.substr(0, 800);
    var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    var theMonth = months[date.getMonth()];
    var theYear = date.getFullYear();

Wednesday, 11 December 2013

Recursive delete for blogs and forums

Let's say, you've developed a blog or forum and you need to delete some entries. You will also want to delete the responses to those entries. In this example we'll use a table structure like this, where 'refid' is a field used to associate a response with it's referer :
In our PHP we want to go through each blog entry which we'd like to delete and ascertain it's responses identified by 'refid' before deleting it. Thus :
function deleterecursiveblog($id)
    $q = "SELECT * FROM `blog` WHERE `refid`='{$id}'";  
    $result = mysqli_query($con,$q);
      foreach($result as $key)
    $q = "DELETE FROM `blog` WHERE `id`='{$id}'";  
    $result = mysqli_query($con,$q);