0

Can anyone help me how to create request to Twitter ads api? I have try to run example in this page GET accounts, i run that example URL to my browser but it give error "This page can't be reached". I want try to create this request without sdk, can anyone help me?

dradewa
  • 25
  • 4

1 Answers1

1

Yes because you need to authenticate your request, there are multiple ways of doing so.

Use an application like Postman to post your requests because it provides easy way to configure authentication as well, or you can try curl.

Here is one such example, build authorization header

Building the header string
To build the header string, imagine writing to a string named DST.

Append the string “OAuth ” (including the space at the end) to DST.
For each key/value pair of the 7 parameters listed above:
Percent encode the key and append it to DST.
Append the equals character ‘=’ to DST.
Append a double quote ‘”’ to DST.
Percent encode the value and append it to DST.
Append a double quote ‘”’ to DST.
If there are key/value pairs remaining, append a comma ‘,’ and a space ‘ ‘ to DST.
Pay particular attention to the percent encoding of the values when building 
this string. For example, the oauth_signature value of 
tnnArxj06cWHq44gCs1OSKk/jLY= must be encoded as tnnArxj06cWHq44gCs1OSKk%2FjLY%3D.

OAuth oauth_consumer_key="xvz1evFS4wEEPTGEFPHBog", 
oauth_nonce="kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg", 
oauth_signature="tnnArxj06cWHq44gCs1OSKk%2FjLY%3D", 
oauth_signature_method="HMAC-SHA1", oauth_timestamp="1318622958", 
oauth_token="370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb", 
oauth_version="1.0"
MithunS
  • 485
  • 7
  • 28
  • thanks for answer it, i will try it soon. then it really different with facebook then, at facebook i can build single url with access_token on it, but can i do this with twitter? @MithunS – dradewa Jul 12 '18 at 04:58
  • 1
    Using access tokens with twitter is possible. In this case, you would generate an access token and a secret for using it from an application. There are a couple of things to keep in mind though. `Your application only needs to make requests on behalf of a single user You wish to test API functionality from a single account only. ` In short, with twitter access tokens are more for apps than for users. – MithunS Jul 12 '18 at 21:02