Import your Foursquare/Swarm checkins to your Micropub-enabled website

Overview

Swarm Checkins Import

Import your Foursquare/Swarm checkins to your Micropub-enabled website

Installation

You'll need PHP and Composer to install this project.

From the project folder, run:

composer install

Usage

There are three parts to the full flow:

  • Import checkins from Foursquare
  • Import photos from Foursquare
  • Publish checkins to your website via Micropub

Authenticate

You'll need to get an access token to fetch your data from Foursquare, as well as an access token to publish to your website. You can do this manually yourself, or you can use OwnYourSwarm to get both access tokens.

Log in to https://ownyourswarm.p3k.io and set it up as if you were going to use it to import your future checkins.

Then visit this page:

https://ownyourswarm.p3k.io/user/details

This page will show you your Foursquare and Micropub access tokens. Copy the configuration from the lower text area and save it in a file called credentials.json.

If you don't want OwnYourSwarm to automatically publish future checkins to your website, click the "Disconnect Foursquare" button at the bottom of your dashboard page.

Import

First, run the init script which will check your configuration and save some initial data:

php init.php

You should see the following output if everything worked:

Saved user info to checkins/user.json
Saved Micropub config to checkins/micropub.json

Now you can run the import script which will create JSON files for each of your Swarm checkins in the checkins folder.

php import-checkins.php

This will start with the most recent checkin and page back through your account until it can't find any more checkins.

Next, you'll want to download all the photos from the checkins as well. This will take considerably longer than the first import.

php import-photos.php

Publish

To publish your checkins to your website, make sure your website supports Micropub, specifically the JSON format. For details of the Micropub request, see the OwnYourSwarm documentation.

If your Micropub endpoint has a media endpoint, photos will be first uploaded to your media endpoint and that URL will be sent instead of the Foursquare photo URL.

You'll probably want to first import just one checkin to make sure things are working with your website being able to handle the checkin that the website sends.

php publish.php

Running the publish command with no options will publish only the latest checkin to your website, then it will exit. This will give you a chance to make sure everything looks good with the checkin you imported.

The output will show you the URL of your published checkin.

When you're ready to publish all your checkins, run with the --all option:

php publish --all

Sit back and get some coffee and watch as all your checkins are published!

Note: When a checkin is successfully published, it will create a .txt file next to the source .json file to keep track of the published URL of the checkin, to avoid publishing checkins multiple times. If you want to reset the import script to publish all checkins again, you can remove all the .txt files:

rm checkins/*/*/*/*.txt

Storage Format

Checkins are saved as JSON files in the checkins folder, in subfolders for the year/month/day. The filename is the hour/minute/second of the checkin, in local time to the checkin. For example:

checkins/
        /2015/
             /02/
                /20/
                   /155627.json
                   /161314.json
                   /184800.json
                /21/
                   /081200.json
                   /082807.json

The JSON file is the exact API response from Foursquare for the checkin. For example:

{
    "id": "54e7c9ab498e77e63f4eb5c6",
    "createdAt": 1424476587,
    "type": "checkin",
    "entities": [],
    "shout": "Picking up food!",
    "timeZoneOffset": -480,
    "venue": {
        "id": "4a85dc38f964a52072ff1fe3",
        "name": "Great Harvest Bread",
        "contact": {
            "phone": "5032248583",
            "formattedPhone": "(503) 224-8583",
            "twitter": "greatharvest"
        },
        "location": {
            "address": "810 SW 2nd Ave",
            "crossStreet": "SW Yamhill St",
            "lat": 45.51723237255434,
            "lng": -122.67498414631359,
            "postalCode": "97204",
            "cc": "US",
            "city": "Portland",
            "state": "OR",
            "country": "United States",
            "formattedAddress": [
                "810 SW 2nd Ave (SW Yamhill St)",
                "Portland, OR 97204"
            ]
        },
        "categories": [
            {
                "id": "4bf58dd8d48988d16a941735",
                "name": "Bakery",
                "pluralName": "Bakeries",
                "shortName": "Bakery",
                "icon": {
                    "prefix": "https://ss3.4sqi.net/img/categories_v2/food/bakery_",
                    "suffix": ".png"
                },
                "primary": true
            }
        ],
        ...
    },
    ...
}

Photos are saved next to the JSON files and are named with the photo_id property from the API.

If the checkin has one or more photos, there will be a photos array in the checkin JSON:

    "id": "55198007498eb9d85e8e5234",
    "createdAt": 1427734535,
    "type": "checkin",
    ...
    "photos": {
        "count": 1,
        "items": [
            {
                "id": "5519800a498e845f01aee3fb",
                "createdAt": 1427734538,
                "source": {
                    "name": "Swarm for iOS",
                    "url": "https://www.swarmapp.com"
                },
                "prefix": "https://fastly.4sqi.net/img/general/",
                "suffix": "/59164_t3BNST0CcWIG7KJD0D0IvLDDAgpoZnmII9lrVLqlKqU.jpg",
                "width": 1440,
                "height": 1920,
                "demoted": false,
                "user": {
                    "id": "59164",
                    "firstName": "aaronpk",
                    "gender": "male",
                    "countryCode": "US",
                    "relationship": "self",
                    "photo": {
                        "prefix": "https://fastly.4sqi.net/img/user/",
                        "suffix": "/59164_AwCOMSY2_cGQ0vElNLiFchw0KwiHBrmiHtuau30m-ykdT3z8io8tClE1M2t2oNw5EGVDeff34.jpg"
                    }
                },
                "visibility": "public"
            }
        ],
        "layout": {
            "name": "single"
        }
    },

The photo will be saved as {id}.jpg in the same folder as the checkin. For example, checkins/2015/03/30/5519800a498e845f01aee3fb.jpg.

You might also like...
Multi-language field export/import tool for ProcessWire

Language field export/import for ProcessWire Typically the way you translate page field values in ProcessWire is to edit a page, view the text in one

This is a class that allows you to import posts from Wix into WordPress.

Wix Posts to WordPress This is a class that allows you to import posts from Wix into WordPress. Requirements Please make sure you have the following i

Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.
Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.

Laravel Blog Have you worked with Wordpress? Developers call this package wordpress-like laravel blog. Give our package a Star to support us ⭐ 😍 Inst

The Assure Alliance support website. This website is based on Questions2Answers and is a forum for support using Biblical Tools

The Assure Alliance support website. This website is based on Questions2Answers and is a forum for support using Biblical Tools

Talkino allows you to integrate multi social messengers and contact into your website and enable your users to contact you using multi social messengers' accounts.

Talkino Welcome to our GitHub Repository Talkino is a click to chat plugin to show your agents’ multiple social messengers, phone and emails on the ch

The simplest way to create a dynamic sitemap for your self-coded website which you have made by using PHP/HTML/CSS/Js etc... Scripts.

Sitemap_index.xml The simplest way to create a dynamic sitemap for your self-coded website which you have made by using PHP/HTML/CSS/Js etc... Scripts

Add a logger to your Kirby3 website
Add a logger to your Kirby3 website

A Website logger for Kirby3 Commercial Usage This plugin is free but if you use it in a commercial project please consider to buy me a 🍺 Installation

Owner
Aaron Parecki
Spec Editor • Cofounder of #indieweb • I maintain oauth.net • I am an Avocado 🥑
Aaron Parecki
Q2A plugin that allows users to import and export Q2A configuration

Configuration Manager [by Gabriel Zanetti] Description Configuration Manager is a Question2Answer plugin that allows users to import and export Q2A co

Gabriel Zanetti 1 Nov 22, 2021
Magento-bulk - Bulk Import/Export helper scripts and CLI utilities for Magento Commerce

Magento Bulk Bulk operations for Magento. Configuration Copy config.php.sample to config.php and edit it. Product Attribute Management List All Attrib

Bippo Indonesia 23 Dec 20, 2022
Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel

Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel , mapping of any format, Google Sheet, data and price modification, improved speed and a lot more!

Firebear Studio 173 Dec 17, 2022
Import/Export configuration data in Magento 2 via CLI.

ConfigImportExport This module provides new CLI commands for Magento 2 to import/export data in/from core_config_data. This module is inspired by the

semaio 135 Dec 9, 2022
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

EcomDev B.V. 51 Dec 5, 2022
Import/Export configuration data in Magento 2 via CLI.

ConfigImportExport This module provides new CLI commands for Magento 2 to import/export data in/from core_config_data. This module is inspired by the

semaio 117 Mar 23, 2022
Magento 2 - Improved Import / Export extension

Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel , mapping of any format, Google Sheet, data and price modification, improved speed and a lot more!

Firebear Studio 173 Dec 17, 2022
Import data from and export data to a range of different file formats and media

Ddeboer Data Import library This library has been renamed to PortPHP and will be deprecated. Please use PortPHP instead. Introduction This PHP library

David de Boer 570 Dec 27, 2022
Gettext is a PHP (^7.2) library to import/export/edit gettext from PO, MO, PHP, JS files, etc.

Gettext Note: this is the documentation of the new 5.x version. Go to 4.x branch if you're looking for the old 4.x version Created by Oscar Otero http

Gettext 651 Dec 29, 2022
Neo Integrator adalah alat bantu untuk import data ke Neo Feeder dengan cara copy paste saja. bersifat free dan opensource. Semoga Bermanfaat.

Neo-Integrator Penerus dari SimpleFeeder, yang berubah jadi Excel2Feeder dan bertransformasi menjadi Neo-integrator Last Update : 16-05-2022 Capture :

null 9 Nov 26, 2022