Code Monkey home page Code Monkey logo

workflowy-php's Introduction

Version

WorkflowyPHP

An unofficial WorkFlowy API written in PHP.


Disclaimer

The aim of the API is to keep things simple. Please keep in mind that it is an unofficial tool, and it may stop working at any time.

So, I strongly recommend you not to manipulate sensitive data with this API, and be sure to make regular backups of your lists.

Installation

By using Composer:

{
    "require": {
        "johansatge/workflowy-php": "0.1"
    }
}

If you do not use Composer, you can download the source files, install them anywhere on your project, and call the providden autoloader file:

<?php require_once '/your/project/root/path/workflowy-php/src/autoload.php';

Usage

Login API

Because of the unofficial status of the API, you have to login first, by using your regular credentials, before being able to perform requests on your data.

use WorkFlowyPHP\WorkFlowy;
use WorkFlowyPHP\WorkFlowyException;
try
{
    $session_id = WorkFlowy::login('[email protected]', 'password');
}
catch (WorkFlowyException $e)
{
    var_dump($e->getMessage());
}

The $session_id variable will be used later, when performing requests.

You have to use your unencoded password in your code. So I strongly advise you to store it in a different file, or ask it once to the user, then store the session ID. (But keep in mind that the session does not last forever.) This is a huge limitation, but for now there is no workaround.

Lists API

Lists-related stuff is managed with the recursive WorkFlowySublist class.

First, you will need to get the main (root) list.

use WorkFlowyPHP\WorkFlowyList;

$list_request = new WorkFlowyList($session_id);
$list = $list_request->getList();

Then, you will be able to perform the following operations on the resulting $list, or its sublists.

Get the informations of a list

Function Returns Description
$list->getID(); string Get the ID of the list
$list->getName(); string Get the name of the list
$list->getDescription(); string Get the description of the list
$list->getParent(); WorkFlowySublist Get the parent of the list
$list->isComplete(); boolean Get the status of the list
$list->getCompletedTime(); int Get the completed time of the list (Unix timestamp)
$list->getLastModifiedTime(); int Get the last modified time of the list (Unix timestamp)
$list->getOPML(); string Get the list and its sublists as an OPML string
$list->getSublists(); array Get the sublists of the list
$list->searchSublist('/My sublist name/'); WorkFlowySublist Returns the first child list matching the given name
$list->searchSublist('/My sublist name/', array('get_all' => true)); array Returns all children lists matching the given name

Edit the informations of a list

Function Parameters Description
$list->setName('My sublist'); string Sets the list name
$list->setDescription('My sublist description'); string Sets the list description
$list->setParent($parent_list, 2); WorkFlowySublist,int Sets the list parent and its position
$list->setComplete(true); boolean Sets the list status
$list->createSublist('My sublist name', 'My sublist description', 9); string,string,int Creates a sublist

The methods below are used to edit data.

Keep in mind that they will send requests to the server, but not update the existing variables.

For instance, if you change the parent of a list and call the getSublists() method on its old parent, the list will still be present in the resulting array.

Account API

Function Returns Description
$account_request = new WorkFlowyAccount($session_id); WorkFlowyAccount Gets an account object
$account_request->getUsername(); string Gets his username
$account_request->getEmail(); string Gets his email address
$account_request->getTheme(); string Gets his selected theme
$account_request->getItemsCreatedInMonth(); int Gets the number of items created during the month
$account_request->getMonthlyQuota(); int Gets his monthly quota
$account_request->getRegistrationDate('d-m-Y'); string Gets his registration date
Leave the format empty to use the default value ('Y-m-d H:i:s')
$account_request->getRegistrationDate('timestamp'); string Gets his registration time

Changelog

Version Date Notes
0.2.3 2019-05-17 Fix authentication process (#10)
0.2.2 2019-02-13 Fix authentication process (#8)
0.2.1 2018-11-11 Fix getLastModifiedTime() and getCompletedTime() methods
Internal WorkFlowy API started returning timestamps in seconds
0.2.0 2018-07-21 Fix getItemsCreatedInMmonth() method naming (renamed to getItemsCreatedInMonth())
Update documentation
Update sample code
0.1.3 2017-02-28 Add $list->getCompletedTime() & $list->getLastModifiedTime() methods (#5)
Fix OPML encoding (#4)
0.1.2 2016-06-26 Fix searchSublistwith get_all option (@hirechrismeyers)
0.1.1 2015-08-25 Fix case of filenames (@citywill)
0.1 2015-01-01 Initial version

License

This project is released under the MIT License.

Credits

workflowy-php's People

Contributors

citywill avatar johansatge avatar jrmgx avatar tophmey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

workflowy-php's Issues

Could not open the session with those credentials

Hello,

first of all thank you for this unofficial library, it is a pleasure to use and very handy.
That being said ; and with a fully understanding on the unofficial state ;
it seems that from today it does not work anymore.

Given valid credentials I receive this exception

WorkFlowyPHP\WorkFlowyException: Could not open the session with those credentials

I guess that Workflowy may have changed something?
I don't have enough expertise in the reverse engineering of this API to test it further, maybe you can have a look and confirm.

Thank you

$list->getOPML() should be html escaped

Otherwise it will not be possible to restore if formatting tags are used.
Right now I am doing this to backup properly:

    file_put_contents($dir . $date . '.opml.gz', gzencode(
      preg_replace_callback('/(text|_note)="(.*?)"/', function ($matches) {
        return $matches[1] . '="' . htmlspecialchars($matches[2]) . '"';
      }, $list->getOPML())
    ));

Timestamps broken

Hi, I am getting weird timestamps from $list->getLastModifiedTime() (new items in 2356), and nothing from $list->getCompletedTime(). Please check.

Major rewrite question

Hello @johansatge
First let me say thank you, your library worked out of the box and I managed to do with it what I wanted to. But the more I worked with it the more I stubbed my toes on limitations and work arounds I had to do in my code, so I just for fun started messing around with it for a little while.

Well that has balooned into a major rewrite: https://github.com/ChristianRiesen/workflowy-php/tree/welcome-to-2020

I even contacted the workflowy support to ask some pointed questions and they have been very helpful with answers, which led to some more good updates to the library.

The question now is would like me to make a PR with this rewrite to your repo, or would you prefer for me to have this as a completely new fork keeping it on my repo and make it under a new namespace and package name on packagist?
I'm fine with either, but thought I'd ask you first since you did all the heavy lifting to make it work in the first place, for which I would like ot thank you again.

PS: It's not done yet, and I'd like to add some tests as well, but you can see it breaks pretty much everything in the old code.

Can't fetch embedded lists

Thank you for making this API. It's great.

The only problem I seem to be having is that I can't seem to get any data other than the ID from embedded lists (lists that have been shared).

In my returned lists, I can perform getID() on the embedded list, and that is successfully returned. However the name is blank and its sublists are just an empty array.

Is this expected behaviour or do you know of any way to work around this?

Thanks in advance.

Favorited lists

Thanks for the great library!

It'd be nice to have a way to get favorited lists.

searchSublist fails with get_all option

Using: $list->searchSubList('/Name/', array('get_all' => true));

Output: Warning: array_merge(): Argument #2 is not an array in /workflowy-php/src/WorkFlowyPHP/WorkFlowySublist.php on line 159

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.