GithubHelp home page GithubHelp logo

nikolajankovic / pyp-w4-gw-twitter-timeline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bdauer/pyp-w4-gw-twitter-timeline

0.0 2.0 0.0 18 KB

Expand Twitter API with timeline capabilities using external storage service.

License: Creative Commons Attribution Share Alike 4.0 International

Makefile 2.17% Python 97.83%

pyp-w4-gw-twitter-timeline's Introduction

[pyp-w4] Twitter timeline

Today's group work expands the Twitter API with a few new endpoints, including following capabilities and a timeline resource.

Authentication

The authentication method has changed a bit compared to the previous one. We keep using authentication tokens, but instead of sending tokens in the POST payload, we will be sending them now in the request headers.

Authorization: <ACCESS_TOKEN>

As you will notice, all three new resources are @auth_only. That means all of then need the authentication headers to properly work.

Settings

An important difference compared to the previous GW, is that we are not using SQLite DB any more. For this assignment we will work with an external service called https://mlab.com/. It's MongoDB as a service. We will use a regular MongoDB client to connect the database, but instead of having a server running locally, we will connect to the MLab service.

One of the first things you need to do is to create an account in MLab and set up you own database and users there. Once you have all your authentication information and also the name of your database you can fill the blank variables in settings.py.

HOST = None
USERNAME = None
PASSWORD = None
PORT = 13014
DATABASE_NAME = None

Important: Your solution must be posted to Github with your personal MLab settings, because the service is used to run all tests. Don't worry, after we close the PR you can just delete the Database User.

Friendship resource

(Inspired by Twitter's Friendship resource: https://dev.twitter.com/rest/reference/post/friendships/create)

Create a "following relationship" between the authenticated user (provided by the ACCESS_TOKEN) and the user identified by USERNAME.

POST /friendship/
{
  "username": <USERNAME>
}
Authorization: <ACCESS_TOKEN> (header)
>>>
201 Created

Delete a "following relationship" (unfollow):

DELETE /friendship/
{
  "username": <USERNAME>
}
Authorization: <ACCESS_TOKEN> (header)
>>>
204

Followers resource

Get the list of followers for the authenticated user (provided by ACCESS_TOKEN).

GET /followers
Authorization: <ACCESS_TOKEN> (header)
>>>
[
    {
      "username": "<USERNAME>",
      "uri": "/profile/<USERNAME>"
    },
    {
      "username": "<USERNAME>",
      "uri": "/profile/<USERNAME>"
    },
    ...
]

Timeline resource

Returns the list of all tweets posted by all users the current user is following. Current user is given by the provided ACCESS_TOKEN in the request's headers. Tweets are sorted by creation date in descending order (last tweet on top).

GET /timeline
Authorization: <ACCESS_TOKEN> (header)
>>>
[
    {
        'created': '2016-06-11T13:00:10',
        'id': <TWEET_ID>,
        'text': <TWEET_TEXT>,
        'uri': '/tweet/<TWEET_ID>',
        'user_id': <USER_ID>
    },
    ...
]

pyp-w4-gw-twitter-timeline's People

Contributors

martinzugnoni avatar santiagobasulto avatar nikolajankovic avatar

Watchers

James Cloos avatar  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.