I am using Abraham Williams (abraham@abrah.am)'s library “The first PHP Library to support OAuth for Twitter’s REST API.” - https://github.com/abraham/twitteroauth
Here is where I set the webhook
public function setWebhook()
{
$param = [
'url' => config('config_' . env('APP_ENV') . '.application.twitter.webhook_url') //Here is where I set the URL
];
return $this->connection->post('account_activity/all/:env-beta/webhooks', $param);
}
/**
* Digging into the Connection class
* POST wrapper for oAuthRequest.
*/
function post($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response);
}
return $response;
}
/**
* Further dig
*Format and sign an OAuth / API request
*/
function oAuthRequest($url, $method, $parameters) {
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
$url = "{$this->host}{$url}.{$this->format}";
}
$request = \OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
switch ($method) {
case 'GET':
return $this->http($request->to_url(), 'GET');
default:
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
}
}
Here is the outcome