What i am doing -
first i am calling this api -
https://ads-api.twitter.com/3/accounts/18ce54om822/campaigns
and taking entity_id from above api - avc3z,avo2i,avqlt,aww2n
And, passing above entity_id to this api –
https://ads-api.twitter.com/3/stats/accounts/18ce54om822?end_time=2018-11-17&entity=ACCOUNT&entity_ids=avc3z,avo2i,avqlt,aww2n&granularity=TOTAL&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER&start_time=2018-11-12
But it is giving me –
{“errors”:[{“code”:“UNAUTHORIZED_ACCESS”,“message”:“This request is not properly authenticated”}],“request”:{“params”:{}}}
FOR SIGNATURE –
- preparing Oauthparameterstring like –
oauth_consumer_key="######"&oauth_nonce=6MlrXan5p1HU2INHKNXqBLHBqK4k818q&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1532072472&oauth_token="#####"&oauth_version=1.0
- Encoding BaseUrl —
https://ads-api.twitter.com/3/stats/accounts/18ce54om822
After encoding in UTF-8 -
https%3A%2F%2Fads-api.twitter.com%2F3%2Fstats%2Faccounts%2F18ce54om822
- For Signature Base String Like —
GET&https%3A%2F%2Fads-api.twitter.com%2F3%2Fstats%2Faccounts%2F18ce54om822&
- After that encoding ParameterString —
end_time=2018-11-17&entity=ACCOUNT&entity_ids=avc3z,avo2i,avqlt,aww2n&granularity=TOTAL&metric_groups=ENGAGEMENT&oauth_consumer_key=iLxfV4Ic6Wdn5DxBLXftkVjuC&oauth_nonce=6MlrXan5p1HU2INHKNXqBLHBqK4k818q&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1532072472&oauth_token=849562846899970050-Xt9i3Fjooyj02j1H4nrbEBK93iWs5db&oauth_version=1.0&placement=ALL_ON_TWITTER&start_time=2018-11-12
After encoding ParameterString
end_time%3D2018-11-17%26entity%3DACCOUNT%26entity_ids%3Davc3z%2Cavo2i%2Cavqlt%2Caww2n%26granularity%3DTOTAL%26metric_groups%3DENGAGEMENT%26oauth_consumer_key%3DiLxfV4Ic6Wdn5DxBLXftkVjuC%26oauth_nonce%3D6MlrXan5p1HU2INHKNXqBLHBqK4k818q%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1532072472%26oauth_token%3D849562846899970050-Xt9i3Fjooyj02j1H4nrbEBK93iWs5db%26oauth_version%3D1.0%26placement%3DALL_ON_TWITTER%26start_time%3D2018-11-12
- Adding both the encoding Strings —
String encodedFinalSignatureBaseString = finalSignatureBaseString + encodedParameterString;
- I am creating auth_signature using above details–
oauth_signature — ICwpwLjGdiLwm7XTnDY%2B1YxyHfw%3D
- At last, I am calling Api Using Unirest —
URL ---- https://ads-api.twitter.com/3/stats/accounts/18ce54om822?end_time=2018-11-17&entity=ACCOUNT&entity_ids=avc3z,avo2i,avqlt,aww2n&granularity=TOTAL&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER&start_time=2018-11-12
“Authorization”, “OAuth oauth_consumer_key=”####",oauth_nonce=“6MlrXan5p1HU2INHKNXqBLHBqK4k818q”,oauth_signature="#########",oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1532072472”,oauth_token="#########",oauth_version=“1.0”
After All process it is giving me error.
Please help me on this
Thanx