10th September : question


#1

Dear,

I have answered the new questions related to the Developer Accounts Compliance yesterday and confirmed my email.

However, I then got redirected to a « Welcome ! » page telling me that I can now use standard and premium apps (I already used the standard Streaming App prior to the 10th September).

Consequently, I have no info about a pending application or whatsoever as the website seems to behave as my application had already been approved. But I still can’t use my streaming API (using the Twython module from Python).

Could anyone provide me any guidance of this ? Have I been added to an application queue without any website section or email allowing to confirm and monitor its status ?

Thanking you in advance,

Best regards


#2

For the record, the welcome page looks like this :

Am I still supposed to get any approval at this stage ?

Anyway, my app returns the error “401”, which, I believe, means “Unauthorized”…


#3

Have you clicked through to create an app? If you have an existing app, have you checked the upper right drop-down to manage your apps?


#4

Dear andypiper,

Thank you for your answer.

Yes, everything seemed normal in the (existing) apps to me. Here are a few screenshots (with the suppression of my true name) :


#5

Right Ok. So what exactly is not working for you? What code now returns this error? What API endpoint are you using? Please be much more clear and specific.


#6

Here is an example of test code that I use to assess if my access is working or not, using the API endpoint “Twython” from the programming language “Python” :

import twython
import sys
import csv
import http.client
import requests.exceptions

from twython import Twython

APP_KEY = '[Hidden]' 
APP_SECRET = '[Hidden]' 
OAUTH_TOKEN = '[Hidden]' 
OAUTH_TOKEN_SECRET =  '[Hidden]' 

keywords = ['$NFLX']

users =  '[Hidden]' 

t = Twython(app_key=APP_KEY, 
            app_secret=APP_SECRET, 
            oauth_token=OAUTH_TOKEN, 
            oauth_token_secret=OAUTH_TOKEN_SECRET)

from twython import TwythonStreamer



class MyStreamer(TwythonStreamer):
    def on_success(self, data):
            with open('D:/Documents/TwitterAnalyse2/Test999.csv', 'a', encoding='utf-8') as f:
                    print(data['id_str'], data['created_at'], data['text'], '\n\n\n', file=f, sep="º")
    def on_error(self, status_code, data):
        print(status_code)

def stream():
        while True:
                stream = MyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) 
                orig_stdout = sys.stdout
                f = open('D:/Documents/TwitterAnalyse2/Test999.csv', 'a')
                sys.stdout = f
                stream.statuses.filter(track=keywords, follow=users, language=['en', 'fr'])
                sys.stdout = orig_stdout
                f.close()

stream()

When I use the code, it answers correctly and stays activated on “stream()”, but I see no output in the .csv file it is supposed to be writing in, and if I interrupt the code, the only thing I can read in the .csv is “401” on several lines.

Could you tell me if this is related to the new Compliance policy or not ? I have also noticed that I did provide a Callback URL on the « apps » website, but it appeared empty on the « developer » side despite the fact that this is a « required » field. Same observation for the section « What will be the use of your project ? ».

I have filled in both of them and regenerated my 4 tokens, but I still have the « 401 » error. Could it be related to something new about the OAuth 1.0 token and the Callback URL provided ?

Anyway, it had worked like a charm for a whole year until this 10th September.


#7

For further additional information, here is what is provided by the command “twitter.verify_credentials()” :

twitter.verify_credentials()
Out[23]:
{‘contributors_enabled’: False,
‘created_at’: ‘Sat Dec 17 20:52:27 +0000 2016’,
‘default_profile’: True,
‘default_profile_image’: True,
‘description’: ‘’,
‘entities’: {‘description’: {‘urls’: []}},
‘favourites_count’: 17,
‘follow_request_sent’: False,
‘followers_count’: 56,
‘following’: False,
‘friends_count’: 1067,
‘geo_enabled’: False,
‘has_extended_profile’: False,
‘id’: 810226171405279232,
‘id_str’: ‘810226171405279232’,
‘is_translation_enabled’: False,
‘is_translator’: False,
‘lang’: ‘fr’,
‘listed_count’: 1,
‘location’: ‘’,
‘name’: ‘Jacky Delaforet’,
‘needs_phone_verification’: False,
‘notifications’: False,
‘profile_background_color’: ‘F5F8FA’,
‘profile_background_image_url’: None,
‘profile_background_image_url_https’: None,
‘profile_background_tile’: False,
‘profile_image_url’: ‘http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png’,
‘profile_image_url_https’: ‘https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png’,
‘profile_link_color’: ‘1DA1F2’,
‘profile_sidebar_border_color’: ‘C0DEED’,
‘profile_sidebar_fill_color’: ‘DDEEF6’,
‘profile_text_color’: ‘333333’,
‘profile_use_background_image’: True,
‘protected’: False,
‘screen_name’: ‘JackyDeLaForet’,
‘status’: {‘contributors’: None,
‘coordinates’: None,
‘created_at’: ‘Mon Jun 04 05:48:05 +0000 2018’,
‘entities’: {‘hashtags’: [],
‘symbols’: [],
‘urls’: [{‘display_url’: ‘twitter.com/i/web/status/1…’,
‘expanded_url’: ‘https://twitter.com/i/web/status/1003513701058711553’,
‘indices’: [116, 139],
‘url’: ‘https://t.co/gXky1p9yPo’}],
‘user_mentions’: [{‘id’: 1432902236,
‘id_str’: ‘1432902236’,
‘indices’: [0, 15],
‘name’: ‘Tatiana Ventôse’,
‘screen_name’: ‘TatianaVentose’}]},
‘favorite_count’: 0,
‘favorited’: False,
‘geo’: None,
‘id’: 1003513701058711553,
‘id_str’: ‘1003513701058711553’,
‘in_reply_to_screen_name’: ‘JackyDeLaForet’,
‘in_reply_to_status_id’: 1003512798591311877,
‘in_reply_to_status_id_str’: ‘1003512798591311877’,
‘in_reply_to_user_id’: 810226171405279232,
‘in_reply_to_user_id_str’: ‘810226171405279232’,
‘is_quote_status’: False,
‘lang’: ‘fr’,
‘place’: None,
‘retweet_count’: 0,
‘retweeted’: False,
‘source’: ‘Twitter for iPhone’,
‘text’: ‘@TatianaVentose Ils ouvrent grand les bras à la stratégie du prédicateur Qaradawi résumée par sa phrase «\xa0avec vos… https://t.co/gXky1p9yPo’,
‘truncated’: True},
‘statuses_count’: 18,
‘suspended’: False,
‘time_zone’: None,
‘translator_type’: ‘none’,
‘url’: None,
‘utc_offset’: None,
‘verified’: False}

I guess that as long as I receive these infos, my access should be OK ?


#8

Correct, it sounds like an issue with how you’re connecting to the stream, or that there are no events currently available marching your filter.


#9

Well, I also tried to remove any filter and it still provides nothing. And considering how I’m connecting to the stream, I did not make any modification before the 10th September and can’t figure out what could be the source of the issue… Any idea ?


#10

I can assure you that no changes have been made to the streaming service and endpoint you’re connecting to. I’ve just tried connecting with a track parameter of $NFLX and get no results, but get a very small number, slowly and sparsely delivered, for NFLX. I don’t know your user follow filter, so I cannot comment on that.


#11

The code I provided was only meant to test : I collect tweets about 2.000 cashtags a day with the original one. For the test, I also removed the filter with no success (still error 401), and the code then looked like the following :

import twython
import sys
import csv
import http.client
import requests.exceptions

from twython import Twython

APP_KEY = ‘[Hidden]’
APP_SECRET = ‘[Hidden]’
OAUTH_TOKEN = ‘[Hidden]’
OAUTH_TOKEN_SECRET = ‘[Hidden]’

t = Twython(app_key=APP_KEY,
app_secret=APP_SECRET,
oauth_token=OAUTH_TOKEN,
oauth_token_secret=OAUTH_TOKEN_SECRET)

from twython import TwythonStreamer

class MyStreamer(TwythonStreamer):
def on_success(self, data):
with open(‘D:/Documents/TwitterAnalyse2/Test999.csv’, ‘a’, encoding=‘utf-8’) as f:
print(data[‘id_str’], data[‘created_at’], data[‘text’], ‘\n\n\n’, file=f, sep=“º”)
def on_error(self, status_code, data):
print(status_code)

def stream():
while True:
stream = MyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
orig_stdout = sys.stdout
f = open(‘D:/Documents/TwitterAnalyse2/Test999.csv’, ‘a’)
sys.stdout = orig_stdout
f.close()

stream()

I didn’t see any post related to such a new bug in Twython, but I will try another App endpoint to see if the issue stays the same.

Beyond that, is it possible that my access had been restricted for other reasons, like VPN, firewalls, any issue with IP address, … ?

On the one hand, it is reassuring to hear you saying that no change regarding my app’s needs had been made, and that I have a fully-approved profile needing no new Compliance investigation, with no restriction, and so on. But on the other hand, the mystery of the coincidence between the 10th September update and my new problem is still unresolved…

Regarding « Callback URL », is it a field that matters, or putting any URL in it would be fine ?


#12

There was no update on the Twitter side on 10th September, so I’m uncertain what this is referring to.

The fact that you are able to hit the verify_credentials endpoint implies that there are no connectivity issues related to your IP address.

Are you able to use twurl to connect to the streaming endpoint?


#14

I did the “twurl authorize” and got the following message (extract).

image

Don’t know what to do with it, tough, because it gives me an URL I’m supposed to use, what I did. It gave me a PIN code that I introduced into the CMD console and I received a final comment saying “Authorization successful !”

However, I also tried another endapp, “Tweepy”, without any filter, and I still receive “401” as the only answer, with the following code :

from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
#consumer key, consumer secret, access token, access secret.
ckey= [‘Hidden’]
csecret= [‘Hidden’]
atoken= [‘Hidden’]
asecret= [‘Hidden’]

class listener(StreamListener):
def on_data(self, data):
print(data)
return(True)
def on_error(self, status):
print(status)
auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth, listener())
twitterStream.filter()

I also tried the “authorized_tokens” command provided by Twython, and it returned correct tokens, so I guess that the “callback url” is not the cause of the issue.

image

What is amazing is that I’m able to update my Twitter status from Twython or use this code :

But the “stream” API still returns only “401”

Finally, I tried the “streamR” endapp from the “R” language and got a following failure to establish connection :

I’m running out of ideas…


#15

Thanks to some miracle, it is working again… for now.

For the record, here are some of the last things I have tried :

  • I have seen on some posts that a delay between Windows’ and Twitter’s respective clocks could cause “error 401”. I have activated the Windows option about automatic hour update.

  • It seems that users IDs had, in the past, to be introduced in “string” format, but no longer. I have had to convert them into “integers” for them to work.

  • Some other minor code modifications in Twython.

I guess the last Twitter update impacted the endapp in some ways…


#16

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.