当有人使用twitter api和php发布推文时如何获得通知

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

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

The Twitter Account Activity API appears to be the way to do this, now.

"The Account Activity API - All Activities (beta) delivers realtime access to all activities related to a Twitter account via webhooks."

https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/overview