【问题标题】:How to use Twitter Ads Api EndPoint in c#?如何在 c# 中使用 Twitter Ads Api EndPoint?
【发布时间】:2018-12-20 04:38:14
【问题描述】:

谁能帮我创建对 Twitter 广告 API 的请求?我尝试在此页面GET accounts 中运行示例,我将该示例 URL 运行到我的浏览器,但它给出错误“无法访问此页面”。我想尝试在没有 sdk 的情况下创建此请求,有人可以帮我吗?

【问题讨论】:

    标签: c# .net twitter ads-api


    【解决方案1】:

    是的,因为您需要对您的请求进行身份验证,有多种方法可以这样做。

    使用像 Postman 这样的应用程序来发布您的请求,因为它还提供了配置身份验证的简单方法,或者您可以尝试 curl。

    这是一个这样的例子,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"
    

    【讨论】:

    • 感谢您的回答,我会尽快尝试。那么它与 facebook 真的不同,在 facebook 我可以用 access_token 构建单个 url,但我可以用 twitter 来做吗? @MithunS
    • 可以在 twitter 上使用访问令牌。在这种情况下,您将生成一个访问令牌和一个秘密,以便从应用程序中使用它。不过,有几件事要记住。 Your application only needs to make requests on behalf of a single user You wish to test API functionality from a single account only. 简而言之,使用 twitter 访问令牌更多的是用于应用程序而不是用户。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-17
    • 2010-11-08
    • 2015-04-13
    • 1970-01-01
    • 2019-12-25
    相关资源
    最近更新 更多