Twitter Streaming and PHP

php

#1

Hello.
I’m a complete beginner to the Twitter API and I’ve been trying to get PHP to use cURL to call the API but it doesn’t seem to be working for me. The cURL provided works in terminal but I simply get:

HTTP ERROR: 401
Problem accessing ‘/1.1/statuses/filter.json’. Reason:
Unauthorized

When I try to run the PHP script.

The PHP code is:

$data = array(“track” => “twitter”);
$data_string = json_encode($data);

$ch = curl_init(‘https://stream.twitter.com/1.1/statuses/filter.json’);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Authorization: OAuth oauth_consumer_key=“XXXX”’, ‘oauth_nonce=“XXXX”’, ‘oauth_signature=“XXXX”’, ‘oauth_signature_method=“HMAC-SHA1”’, ‘oauth_timestamp=“XXXX”’, ‘oauth_token=“XXXX”’, ‘oauth_version=“1.0”’)
);
$result = curl_exec($ch);

What am I doing wrong, or is there a more proper way of doing this?
Regards.