Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

statusesUpdate() fails to post status because endpoint doesn't support json #48

@bwegrzyn

Description

@bwegrzyn

The statusesUpdate() method that is used to post a new status takes all parameters (including status), json_encodes them, and adds them to the body of the request. It then makes a POST request with Content-Type set to application/json.

Unfortunately, it appears that the /1.1/statuses/update.json endpoint does not support this. It requires the status text to be passed as a parameter on the url as such /1.1/statuses/update.json?status=test.

This means that the statusesUpdate() method fails to post a status with the response being:

{"errors":[{"code":170,"message":"Missing required parameter: status."}]}

Looks like this "bug" was introduced in #41.

Code to reproduce the issue

$client->statusesUpdate('test status');

Expected results

JSON of the tweet that was posted.

Actual results

{"errors":[{"code":170,"message":"Missing required parameter: status."}]}

This can be verified using the Twurl tool:

$ twurl --header "Content-Type: application/json" -X POST -d '{"status": "test status"}' /1.1/statuses/update.json
{"errors":[{"code":170,"message":"Missing required parameter: status."}]}

$ twurl -X POST -d 'status=test status' /1.1/statuses/update.json
{"created_at":"Sat Oct 28 07:32:08 +0000 2017","id":924176943666290689,...}

$ twurl --header "Content-Type: application/json" -X POST "/1.1/statuses/update.json?status=test"
{"created_at":"Sat Oct 28 07:32:52 +0000 2017","id":924177129331351552,...}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions