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

Get DebugInfo and UsageInfo on PagingResult #126

Closed
OwlLaboratory opened this issue Jun 5, 2019 · 3 comments
Closed

Get DebugInfo and UsageInfo on PagingResult #126

OwlLaboratory opened this issue Jun 5, 2019 · 3 comments

Comments

@OwlLaboratory
Copy link

OwlLaboratory commented Jun 5, 2019

It is, at the moment, not possible to get DebugInfo or UsageInfo from a request made using PagingResult.Next() method.

I need this to check the Ad Account rate limit within my for loop.
Example:

var app = fb.New("MY_APP_ID", "MY_APP_SECRET")
var session = app.Session("MY_TOKEN")

session.SetDebug(fb.DEBUG_ALL)

result, _ := session.Get("/MY_AD_ACCOUNT_ID/activities", fb.Params{
    "fields": "event_time,event_type,object_id,object_type",
    "limit": 100,
})
// Here I can call result.DebugInfo() to check to first request only
paging, _ := res.Paging(session)

noMore := false
for !noMore {
    var results = paging.Data()
    // Do something with the data

    // Check the X-Ad-Account-Usage header before making the next request -> not possible
    noMore, _ = paging.Next()
}

P.S: Since v3.3 a new rate limit header X-Ad-Account-Usage has been added for request made on the Marketing API, it would be great to add it in the UsageInfo struct too.

Regards

@huandu
Copy link
Owner

huandu commented Jun 6, 2019

DebugInfo and UsageInfo are fields in Result, while the new rate limit header is stored in response header. From my understanding, you're asking for a new API in PageResult to get current page's rate limit information in response header.

Correct me if I didn't read right. This feature is not complex. I can do it in a few days after I get your confirmation.

@OwlLaboratory
Copy link
Author

Exactly, you got this right, having something like paging.DebugInfo() to get the rate limit information of the last request made.

Thanks.

@huandu
Copy link
Owner

huandu commented Jun 6, 2019

Got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants