Search code examples
phptwitter

how to get notification when someone posts a tweet using twitter api and php


I want to save the notification from specific user in friend list in mysql database using php and twitter api


Solution

  • Twitter has two main APIs. HTTP REST and Stream API so you could do that two ways but I think PHP is only suitable for HTTP API since PHP is not multithreaded.

    With PHP and cURL extension you could periodically poll the HTTP Twitter API to look for changes on user you are following.

    I would use the Stream API which already has a Java client implemented by Twitter staff that works like a charm and receives the updates in RT. For further details:

    REST API: https://dev.twitter.com/rest/public

    Streaming API https://dev.twitter.com/streaming/overview

    Hosebird (Streaming client by Twitter) https://github.com/twitter/hbc

    Hope it helps