xdevplatform / account-activity-dashboard

Sample web app and helper scripts to get started with the premium Account Activity API
Apache License 2.0
169 stars 96 forks source link

Documentation incorrect #8

Open m-grzybek-first10 opened 5 years ago

m-grzybek-first10 commented 5 years ago

Hi, I'm wondering why is documentation totally different than this example? I mean creating webhook in that case - https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/api-reference/aaa-premium#post-account-activity-all-env-name-webhooks ?

Or am I missing something?

andypiper commented 5 years ago

Hey there, what specifically are you referring to that is different? I can happily get the documentation updated as needed. Are you referring to the OAuth mode for webhook registration, or something else?

m-grzybek-first10 commented 5 years ago

Hi @andypiper, yeah sorry for not being specific enough. Exactly, I meant auth for webhook registration and adding subscription. Looks like it's totally different than the examples scripts in that repo (which actually works).

andypiper commented 5 years ago

I'll open this internally for our documentation, and I'll leave this issue open for now as a reminder.

Mrwh0 commented 5 years ago

is this still valid? $ curl --request POST --url 'https://api.twitter.com/1.1/account_activity/all/:ENV_NAME/webhooks.json?url=https%3A%2F%2Fyour_domain.com%2Fwebhook%2Ftwitter' --header 'authorization: OAuth oauth_consumer_key="CONSUMER_KEY", oauth_nonce="GENERATED", oauth_signature="GENERATED", oauth_signature_method="HMAC-SHA1", oauth_timestamp="GENERATED", oauth_token="ACCESS_TOKEN", oauth_version="1.0"'

im getting this error {"errors":[{"code":32,"message":"Could not authenticate you."}]}

can't subscribe to account activity api

Arkalo2 commented 4 years ago

I have the same error. Do you find a solution ? @Mrwh0

renebizelli commented 4 years ago

Hi.. I have the same error..

Mrwh0 commented 4 years ago

well i set up a flask_rest_enpoint.py

#!/usr/bin/python3.6
#-*- coding: utf-8 -*-
from flask import Flask, request , abort , make_response , jsonify
import base64
import hashlib
import hmac
import json
TWITTER_CONSUMER_SECRET = b'your_API_secret_key_here'
app = Flask(__name__)
@app.route("/webhook/twitter", methods=['GET'])
def webhook_challenge():
    try:
        if request.args.get('crc_token'):
            sha256_hash_digest = hmac.new(TWITTER_CONSUMER_SECRET,bytes(request.args.get('crc_token'),"utf-8"), digestmod=hashlib.sha256).digest()
            response = {
             'response_token': 'sha256=' + (base64.b64encode(sha256_hash_digest)).decode("utf-8")
            }
            return json.dumps(response)
    except:
        abort(make_response(jsonify(message="Internal Server Error"), 500))
if __name__ == "__main__":
   app.run(host='0.0.0.0', port=5060)

run that rest server and use the account-activity-dashboard https://github.com/twitterdev/account-activity-dashboard

  1. create the webhook config node example_scripts/webhook_management/create-webhook-config.js -e your_enviroment_here -u https://yout_domain.com_here/webhook/twitter response : {"id":"webhook_config_id","url":"https://your_domain.com/webhook/twitter","valid":true,"created_timestamp":"a_cool_unix_timestamp"}

  2. if you need re-validate the webhook node example_scripts/webhook_management/validate-webhook-config.js -e your_enviroment_here -i the_webhook_config_id_here

hope it helps..

geekgonecrazy commented 3 years ago

Having recently integrated. I would ask that this feedback be relayed to the documentation teams in twitter. :pray:

If we wouldn't have discovered this repo we would not have been able to finish an integration. Many of the endpoints mentioned in the documentation around registering a webhook, registering subscriptions etc weren't even the right endpoint in the documentation. We had to locate the correct one from the code here.

andypiper commented 3 years ago

Can you be specific so that we can fix the reference documentation?

geekgonecrazy commented 3 years ago

Unfortunately we pushed our way through it and managed to find this code base with the correct api's. So with out going through it with out the knowledge again I wouldn't be able to find it.

I think this is an example of one:

https://developer.twitter.com/en/docs/twitter-api/enterprise/account-activity-api/api-reference/aaa-enterprise#get-account-activity-webhooks

https://api.twitter.com/1.1/account_activity/webhooks.json but needs environment like found: https://github.com/twitterdev/account-activity-dashboard/blob/master/example_scripts/webhook_management/delete-webhook-config.js#L8