Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get x_rate_limit_remaining #469

Closed
adiospeds opened this issue May 19, 2016 · 2 comments
Closed

Unable to get x_rate_limit_remaining #469

adiospeds opened this issue May 19, 2016 · 2 comments

Comments

@adiospeds
Copy link

adiospeds commented May 19, 2016

I was developing a simple function to get the id's of followers. I get the results but I am not able to get the headers info so that I can consider the x_rate_limit_remaining.
The function is :

function get_id_of_followers() {
    $access_token = $_SESSION['access_token'];
    $connection = new TwitterOauth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
    $data0 = get_class_methods($connection);
    echo "<pre> D0 ", print_r($data0, true), "</pre>";
    $data1 = $connection->getLastXHeaders();
    echo "<pre> D1 ", print_r($data1, true), "</pre>";
    $data2 = $connection->getLastXHeaders()["x_rate_limit_remaining"];
    echo "<pre> D2 ", $data2, "</pre>";
    $data3 = $connection->get('followers/ids');
    echo "<pre> D3 ", print_r($data3, true), "</pre>";
}

The Output from the function is as follows:

 D0
Array
(
    [0] => __construct
    [1] => setOauthToken
    [2] => getLastApiPath
    [3] => getLastHttpCode
    [4] => getLastXHeaders
    [5] => getLastBody
    [6] => resetLastResponse
    [7] => url
    [8] => oauth
    [9] => oauth2
    [10] => get
    [11] => post
    [12] => delete
    [13] => put
    [14] => upload
    [15] => setTimeouts
    [16] => setDecodeJsonAsArray
    [17] => setUserAgent
    [18] => setProxy
    [19] => setGzipEncoding
)


D1 
Array
(
)


 D2 

D3 
stdClass Object
(
    [ids] => Array
        (
            [0] => 730017479360045056
            [1] => 4716372642
            [2] => 709411090980020224
            [3] => 4905437529
            [4] => 709964576868200449
            [5] => 228648311
            [6] => 3190604329
            [7] => 4298659035
            [8] => 378112124
            [9] => 4554579372
            [10] => 3845238492
            [11] => 3009354738
records retrived upto 5000

Now I am able to get the response(D3) however, Why is my headers(D2) array returning as null ?

@abraham
Copy link
Owner

abraham commented May 21, 2016

You're code works fine for me.

<pre> D1 Array
(
    [x_access_level] => read-write
    [x_connection_hash] => 243162748c890e36060589705b4f6450
    [x_content_type_options] => nosniff
    [x_frame_options] => SAMEORIGIN
    [x_rate_limit_limit] => 15
    [x_rate_limit_remaining] => 14
    [x_rate_limit_reset] => 1463852701
    [x_response_time] => 119
    [x_transaction] => fa0b0434dbff3960
    [x_twitter_response_tags] => BouncerCompliant
    [x_xss_protection] => 1; mode=block
)
</pre>
<pre> D2 14</pre>

@adiospeds
Copy link
Author

aha yes .. i got solution to the . basically i was trying to retrieve the headers info before making the get call
Here's the solution --> http://stackoverflow.com/questions/37313931/php-website-twitter-api-abraham-oauth-unable-to-find-x-rate-limit-remaining

Repository owner locked and limited conversation to collaborators Dec 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants