Code Monkey home page Code Monkey logo

snsapi's Introduction

SNSAPI

A cross-platform middleware for Social Networking Services (SNS):

Lightning Demo 1 -- Read Twitter Timeline

Step 1.

Register user and developer on Twitter. Apply for application keys and access tokens.

Step 2.

Save the following codes to mytest.py in the root dir of this project:

from snscli import *
nc = new_channel('TwitterStatus')
nc['app_key'] = 'Your Consumer Key from dev.twitter.com'
nc['app_secret'] = 'Your Consumer Secret from dev.twitter.com'
nc['access_key'] = 'Your Access Token from dev.twitter.com'
nc['access_secret'] = 'Your Access Token Secret from dev.twitter.com'
add_channel(nc)
print home_timeline()

Filling your app credentials in the above script: app_key, app_secret, access_key, access_key.

Step 3.

Try it by python mytest.py. You will see your home timeline from twitter.

Remarks

SNSApi unifies the interfaces of all SNS such that retrieving new messages from all other platforms are the same:

  • Create a new channel configuration and add_channel it.
  • Invoke a single home_timeline() to obtain an aggregated timeline from all channels in a batch.

Lightning Demo 2 -- Backup Your Data

Step 1.

Configure a channel.json file with two channels:

  • One is called "myrenren" and it interfaces with Renren (an OSN in China).
  • The other is called "mysqlite" and it interfaces with a SQLite3 DB.

See one example channel.json configuration.

Step 2.

Save the following codes to backup.py in the root dir of this project:

from snsapi.snspocket import SNSPocket
sp = SNSPocket()
sp.load_config()
sp.auth()

ml = sp['myrenren'].home_timeline()
for m in ml:
    sp['mysqlite'].update(m)

Step 3.

Try it by python backup.py. Now your timeline of Renren (latest 20 messages by default) is backed up to the SQLite DB. You can run this script on a regular basis to backup data from all kinds of SNS.

Remarks

SNSApi unifies the data structures of all SNS so as to enable flexible/ programmable inter-operation between those services:

  • Backup one message in SQLite is just "update a status" there.
  • In order to read those messages, just invoke home_timeline of your SQLite channel.
  • The data in SQLite DB are ready for further analysis. For example, I remember someone said that "snsapi is awesome". Who posted it? I can not recall. Now, enter sqlite and use one line of command to get the answer: select * from message where text like '%snsapi%';.
  • You can also use EMail or RSS to distribute your statuses and follow the updates of your friends.
  • When there are new platforms, it's just one configuration away to use them. The intervention from app developer is not needed.

Lightning Demo 3 -- An Ad-Hoc DSN

Decentralized Social Network (DSN) is the next paradigm of social networking. Current centralized services have a lot of problems, e.g. Spying for free.

SNSApi is just a middleware to offload your burden in interfacing with different platforms. Now, try to build something without worrying about the interfacing detials.

See RSoc Community Page if you are interested.

Supported Platforms

Enther the interactive shell by python -i snscli.py. Get the supported platforms as follows:

Supported platforms:
   * Email
   * FacebookFeed
   * RSS
   * RSS2RW
   * RSSSummary
   * RenrenBlog
   * RenrenFeed
   * RenrenPhoto
   * RenrenShare
   * RenrenStatus
   * RenrenStatusDirect
   * SQLite
   * SinaWeiboBase
   * SinaWeiboStatus
   * SinaWeiboWapStatus
   * TencentWeiboStatus
   * TwitterStatus
   * ...

More platforms are coming! Please join us!

Get Started

  • Clone and install dependencies via pip. Then you are ready to go. See installation guide if you need more detailed information. See troubleshooting page if you encounter problems in your initial tests.
  • We have several demo apps in this repo. You can start with them and see how to use those classes of SNSAPI.
  • Users who don't want to write Python or other non-Python programmers can start with our command-line-interface (snscli.py). The official SNSAPI website should get your started quickly along this line. This CLI can allow interfacing with other languages using STDIN/ STDOUT.
  • Users who are not comfortable with CLI can use the graphical-user-interface (snsgui.py). See more user interfaces.

Resources

License

copyleft

All materials of this project are released to public domain, except for the followings:

  • snsapi/third/*: The third party modules. Please refer to their original LICENSE. We have pointers in snsapi/third/README.md for those third party modules.

Other

master dev Analytics

snsapi's People

Contributors

hupili avatar fqj1994 avatar uxian avatar iptux avatar hzhua avatar guori12321 avatar antsword avatar kelvin-zhong avatar cllu avatar

Watchers

Shaw Yan avatar

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.