/**
* Create the API access object. Requires an array of settings::
* oauth access token, oauth access token secret, consumer key, consumer secret
* These are all available by creating your own application on dev.twitter.com
* Requires the cURL library
*
/**
* Create the API access object. Requires an array of settings::
* oauth access token, oauth access token secret, consumer key, consumer secret
* These are all available by creating your own application on dev.twitter.com
* Requires the cURL library
*
if (!isset($settings['oauth_access_token'])
|| !isset($settings['oauth_access_token_secret'])
|| !isset($settings['consumer_key'])
|| !isset($settings['consumer_secret']))
{
if (!isset($settings['oauth_access_token'])
|| !isset($settings['oauth_access_token_secret'])
|| !isset($settings['consumer_key'])
|| !isset($settings['consumer_secret']))
{
- if (!is_null($this->getGetfield()))
- {
- throw new Exception('You can only choose get OR post fields.');
+ if (!is_null($this->getGetfield()))
+ {
+ throw new Exception('You can only choose get OR post fields (post fields include put).');
if (isset($array['status']) && substr($array['status'], 0, 1) === '@')
{
$array['status'] = sprintf("\0%s", $array['status']);
if (isset($array['status']) && substr($array['status'], 0, 1) === '@')
{
$array['status'] = sprintf("\0%s", $array['status']);
* @return \TwitterAPIExchange Instance of self for method chaining
*/
public function setGetfield($string)
{
* @return \TwitterAPIExchange Instance of self for method chaining
*/
public function setGetfield($string)
{
- if (!is_null($this->getPostfields()))
- {
- throw new Exception('You can only choose get OR post fields.');
+ if (!is_null($this->getPostfields()))
+ {
+ throw new Exception('You can only choose get OR post / post fields.');
$getfields = preg_replace('/^\?/', '', explode('&', $string));
$params = array();
$getfields = preg_replace('/^\?/', '', explode('&', $string));
$params = array();
* @return array $this->postfields
*/
public function getPostfields()
{
return $this->postfields;
}
* @return array $this->postfields
*/
public function getPostfields()
{
return $this->postfields;
}
/**
* Build the Oauth object using params set in construct and additionals
* passed to this method. For v1.1, see: https://dev.twitter.com/docs/api/1.1
/**
* Build the Oauth object using params set in construct and additionals
* passed to this method. For v1.1, see: https://dev.twitter.com/docs/api/1.1
- if (!in_array(strtolower($requestMethod), array('post', 'get')))
+ if (!in_array(strtolower($requestMethod), array('post', 'get', 'put', 'delete')))
$consumer_key = $this->consumer_key;
$consumer_secret = $this->consumer_secret;
$oauth_access_token = $this->oauth_access_token;
$oauth_access_token_secret = $this->oauth_access_token_secret;
$consumer_key = $this->consumer_key;
$consumer_secret = $this->consumer_secret;
$oauth_access_token = $this->oauth_access_token;
$oauth_access_token_secret = $this->oauth_access_token_secret;
if (!is_null($getfield))
{
$getfields = str_replace('?', '', explode('&', $getfield));
if (!is_null($getfield))
{
$getfields = str_replace('?', '', explode('&', $getfield));
$composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret);
$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
$oauth['oauth_signature'] = $oauth_signature;
$composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret);
$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
$oauth['oauth_signature'] = $oauth_signature;
* @param boolean $return If true, returns data. This is left in for backward compatibility reasons
* @param array $curlOptions Additional Curl options for this request
*
* @throws \Exception
* @param boolean $return If true, returns data. This is left in for backward compatibility reasons
* @param array $curlOptions Additional Curl options for this request
*
* @throws \Exception
* @return string json If $return param is true, returns json data.
*/
public function performRequest($return = true, $curlOptions = array())
* @return string json If $return param is true, returns json data.
*/
public function performRequest($return = true, $curlOptions = array())
CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => false,
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => false,
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
foreach($oauth as $key => $value)
{
if (in_array($key, array('oauth_consumer_key', 'oauth_nonce', 'oauth_signature',
foreach($oauth as $key => $value)
{
if (in_array($key, array('oauth_consumer_key', 'oauth_nonce', 'oauth_signature',