Hello, I'm Luís, Twitter evangelist here in Brazil. Twitter has several endpoints in the API that allow you to access what you need. It was not clear what language you want to use, but I'll set the example in PHP, since you mentioned it. To connect to the API you need:
Create an app on apps.twitter.com
Get the 4 access keys: consumer_key, consumer_secret, access_token_key, access_token_secret (in your app at apps.twitter.com)
Configure these keys in the library you are going to use:
The most recommended library for PHP is tmhOAuth, see an example of how to search for tweets, available at link :
<?php
require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$code = $tmhOAuth->apponly_request(array(
'method' => 'GET',
'url' => $tmhOAuth->url('1.1/search/tweets'),
'params' => array(
'q' => 'tmhoauth'
)
));
$tmhOAuth->render_response();
You can also get the graph of a user, as the example from the same repository shows: link
I suggest taking a look at the following references: