atymic / twitter

Twitter API for Laravel 5.5+, 6.x, 7.x & 8.x
https://atymic.dev
MIT License
922 stars 290 forks source link

Response format defaults to json, doc update for overriding? #383

Closed ChrisHardie closed 2 years ago

ChrisHardie commented 2 years ago

I noticed today that this call:

Twitter::forApiV2()->getUserByUsername($username);

was returning a JSON string. Reading the docs, I see:

By default responses will be returned as objects. To change this, use the format option in the parameters you pass to any method.

I tried passing 'format' => 'object' but that didn't work. Then I tried 'response_format' => 'object' and that worked.

Could you clarify what the expected default return format is? Should I submit a PR to clarify the param key name in the docs? Thanks!

reliq commented 2 years ago

Hi @ChrisHardie, thank you for reporting this. For API v2 the response format defaults to JSOn, see https://github.com/atymic/twitter/blob/main/src/Concern/ApiV2Behavior.php#L24

I will make an adjustment in the readme to reflect this.