Why do POST methods not work? ( {"errors":[{"message":"Could not authenticate you","code":32}]})


#1

I’m trying to migrate to API v1.1 and I cannot get POST methods to work. GET methods seem to operate properly and that’s all. I need to find a way to post teewts again. I’m trying statuses/update without positive results. This is what I send:

statuses/update (in this thread, oauth_consumer_key & oauth_token have been replaced by KKKKK and TTTTT for obvious reasons):

POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&oauth_consumer_key%3DKKKKK%26oauth_nonce%3DJhVthyMhqGVI%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1371139968%26oauth_token%3DTTTTT%26oauth_version%3D1.0%26status%3Dsdfsdfsdfsdf

I have also removed all oauth_* from the URL an it still doesn’t work.

Any idea? Is this a common issue among all of us? If you can send tweets, I would appreciate if you could clearly describe how to. Thanks

CJ


#2

Hi @cjsoftlab, Have you find any solution for this issue? If you have resolved or find the issue, Can you share the that solution with me. Because Facing the same issue in php.


#3

Which PHP library are you using?


#4

Hi @andypiper, Thank you for your attention.

FYI, I have created my own library according to use, and that library is working fine for GET method. When I use POST method then it through an error like below.

stdClass Object
(
[errors] => Array
(
    [0] => stdClass Object
        (
            [code] => UNAUTHORIZED_ACCESS
            [message] => This request is not properly authenticated
        )

)

[request] => stdClass Object
(
    [params] => stdClass Object
        (
        )

)

)

If you need to review the code then How can I share the code? Or if you have another reference for sample code then share with me.
FYI, I can not use any other library because my library is enough for the use.


#5

Hi @andypiper, Please find the base string

POST&https%3A%2F%2Fads-api.twitter.com%2F1%2Fstats%2Fjobs%2Faccounts%2FXXXXXXXX&end_time%3D2017-04-25%26entity%3DCAMPAIGN%26entity_ids%XXXXX%26granularity%3DTOTAL%26metric_groups%3DENGAGEMENT%26oauth_consumer_key%XXXXXXXXXXXXXXXXXXXXXXX%26oauth_nonce%3D1494827448%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1494827448%26oauth_token%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX%26oauth_version%3D1.0%26placement%3DALL_ON_TWITTER%26platform%3D0%26segmentation_type%3DDEVICES%26start_time%3D2017-04-24

When I use GET method then it works fine. But using POST method it shows an error like above.


#6

Hi @andypiper, If you need anything, please let me know.


#7

I’m not familiar with the Ads API, and encoding OAuth requests is notoriously complicated, which is why I suggested using an established library.

There’s an Ads API PHP SDK here and maybe you could compare how it is calculating the signature. Alternatively, if you’re able to use twurl to make a successful call to the Ads API, you could run a trace on that (the -t option) to compare the signature and base strings.

You can find more assistance on Ads API topics in the relevant categories.


#8

Thank you so much @andypiper