Skip to content

Instantly share code, notes, and snippets.

@michael-erasmus
Created March 7, 2018 17:12
Show Gist options
  • Save michael-erasmus/0cd98a151de5b6aa0cf90727305c40d4 to your computer and use it in GitHub Desktop.
Save michael-erasmus/0cd98a151de5b6aa0cf90727305c40d4 to your computer and use it in GitHub Desktop.
Load twitter error codes into Redshift
import pandas as pd
from rsdf import redshift
table = """
<table border="1">
<thead valign="bottom"><tr class="row-odd"><th class="head">Code</th>
<th class="head">Text</th>
<th class="head">Description</th>
</tr></thead><tbody valign="top"><tr><td>3</td>
<td>Invalid coordinates.<br>
</td>
<td>Corresponds with HTTP 400. The coordinates provided as parameters were not valid for the request.</td>
</tr><tr><td>13</td>
<td>No location associated with the specified IP address.<br>
</td>
<td>Corresponds with HTTP 404. It was not possible to derive a location for the IP address provided as a parameter on the geo search request.</td>
</tr><tr><td>17</td>
<td>No user matches for specified terms.<br>
</td>
<td>Corresponds with HTTP 404. It was not possible to find a user profile matching the parameters specified.</td>
</tr><tr class="row-even"><td>32</td>
<td>Could not authenticate you</td>
<td>Corresponds with HTTP 401. There was an issue with the authentication data for the request.</td>
</tr><tr class="row-odd"><td>34</td>
<td>Sorry, that page does not exist</td>
<td>Corresponds with HTTP 404. The specified resource was not found.</td>
</tr><tr class="row-even"><td>36</td>
<td>You cannot report yourself for spam.</td>
<td>Corresponds with HTTP 403. You cannot use your own user ID in a report spam call.</td>
</tr><tr class="row-odd"><td>44</td>
<td>attachment_url parameter is invalid</td>
<td>Corresponds with HTTP 400. The URL value provided is not a URL that can be attached to this Tweet.</td>
</tr><tr class="row-even"><td>50</td>
<td>User not found.</td>
<td>Corresponds with HTTP 404. The user is not found.</td>
</tr><tr class="row-odd"><td>63</td>
<td>User has been suspended.</td>
<td>Corresponds with HTTP 403 The user account has been suspended and information cannot be retrieved.</td>
</tr><tr class="row-even"><td>64</td>
<td>Your account is suspended and is not permitted to access this feature</td>
<td>Corresponds with HTTP 403. The access token being used belongs to a suspended user.</td>
</tr><tr class="row-odd"><td>68</td>
<td>The Twitter REST API v1 is no longer active. Please migrate to API v1.1.</td>
<td>Corresponds to a HTTP request to a retired v1-era URL.</td>
</tr><tr class="row-even"><td>87</td>
<td>Client is not permitted to perform this action.</td>
<td>Corresponds with HTTP 403. The endpoint called is not a permitted URL.</td>
</tr><tr class="row-odd"><td>88</td>
<td>Rate limit exceeded</td>
<td>The request limit for this resource has been reached for the current rate limit window.</td>
</tr><tr class="row-even"><td>89</td>
<td>Invalid or expired token</td>
<td>The access token used in the request is incorrect or has expired.</td>
</tr><tr class="row-odd"><td>92</td>
<td>SSL is required</td>
<td>Only SSL connections are allowed in the API. Update the request to a secure connection. See <a class="reference external" href="/en/docs/basics/authentication/guides/tls.html">how to connect using TLS</a></td>
</tr><tr class="row-even"><td>93</td>
<td>This application is not allowed to access or delete your direct messages</td>
<td>Corresponds with HTTP 403. The OAuth token does not provide access to Direct Messages.</td>
</tr><tr class="row-odd"><td>99</td>
<td>Unable to verify your credentials.</td>
<td>Corresponds with HTTP 403. The OAuth credentials cannot be validated. Check that the token is still valid.</td>
</tr><tr><td>120</td>
<td>Account update failed: <i>value</i> is too long (maximum is <i>nn</i> characters).<br>
</td>
<td>Corresponds with HTTP 403. Thrown when one of the <i>values</i> passed to the update_profile.json endpoint exceeds the maximum value currently permitted for that field. The error message will specify the allowable maximum number of <i>nn</i> characters.</td>
</tr><tr class="row-even"><td>130</td>
<td>Over capacity</td>
<td>Corresponds with HTTP 503. Twitter is temporarily over capacity.</td>
</tr><tr class="row-odd"><td>131</td>
<td>Internal error</td>
<td>Corresponds with HTTP 500. An unknown internal error occurred.</td>
</tr><tr class="row-even"><td>135</td>
<td>Could not authenticate you</td>
<td>Corresponds with HTTP 401. Timestamp out of bounds (often caused by a clock drift when authenticating - check your system clock)</td>
</tr><tr class="row-odd"><td>144</td>
<td>No status found with that ID.</td>
<td>Corresponds with HTTP 404. The requested Tweet ID is not found (if it existed, it was probably deleted)</td>
</tr><tr class="row-even"><td>150</td>
<td>You cannot send messages to users who are not following you.</td>
<td>Corresponds with HTTP 403. Sending a Direct Message failed.</td>
</tr><tr class="row-odd"><td>151</td>
<td>There was an error sending your message: <i>reason</i></td>
<td>Corresponds with HTTP 403. Sending a Direct Message failed. The <i>reason</i> value will provide more information.</td>
</tr><tr><td>160</td>
<td>You've already requested to follow <i>user</i>.<br>
</td>
<td>Corresponds with HTTP 403. This was a duplicated follow request and a previous request was not yet acknowleged.<br>
</td>
</tr><tr class="row-even"><td>161</td>
<td>You are unable to follow more people at this time</td>
<td>Corresponds with HTTP 403. Thrown when a user cannot follow another user due to some kind of limit</td>
</tr><tr class="row-odd"><td>179</td>
<td>Sorry, you are not authorized to see this status</td>
<td>Corresponds with HTTP 403. Thrown when a Tweet cannot be viewed by the authenticating user, usually due to the Tweet’s author having protected their Tweets.</td>
</tr><tr class="row-even"><td>185</td>
<td>User is over daily status update limit</td>
<td>Corresponds with HTTP 403. Thrown when a Tweet cannot be posted due to the user having no allowance remaining to post. Despite the text in the error message indicating that this error is only thrown when a daily limit is reached, this error will be thrown whenever a posting limitation has been reached. Posting allowances have roaming windows of time of unspecified duration.</td>
</tr><tr><td>186</td>
<td>Tweet needs to be a bit shorter.</td>
<td>Corresponds with HTTP 403. The status text is too long.</td>
</tr><tr class="row-odd"><td>187</td>
<td>Status is a duplicate</td>
<td>The status text has already been Tweeted by the authenticated account.</td>
</tr><tr class="row-even"><td>205</td>
<td>You are over the limit for spam reports.</td>
<td>Corresponds with HTTP 403. The account limit for reporting spam has been reached. Try again later.</td>
</tr><tr class="row-odd"><td>215</td>
<td>Bad authentication data</td>
<td>Corresponds with HTTP 400. The method requires authentication but it was not presented or was wholly invalid.</td>
</tr><tr class="row-even"><td>220</td>
<td>Your credentials do not allow access to this resource.</td>
<td>Corresponds with HTTP 403. The authentication token in use is restricted and cannot access the requested resource.</td>
</tr><tr class="row-odd"><td>226</td>
<td>This request looks like it might be automated. To protect our users from spam and other malicious activity, we can’t complete this action right now.</td>
<td>We constantly monitor and adjust our filters to block spam and malicious activity on the Twitter platform. These systems are tuned in real-time. If you get this response our systems have flagged the Tweet or DM as possibly fitting this profile. If you feel that the Tweet or DM you attempted to create was flagged in error, please report the details around that to us by filing a ticket at <a class="reference external" href="https://support.twitter.com/forms/platform" target="_blank">https://support.twitter.com/forms/platform</a>.</td>
</tr><tr class="row-even"><td>231</td>
<td>User must verify login</td>
<td>Returned as a challenge in xAuth when the user has login verification enabled on their account and needs to be directed to twitter.com to <a class="reference external" href="https://twitter.com/settings/applications" target="_blank">generate a temporary password</a>. Note that xAuth is no longer an available option for authentication on the API.</td>
</tr><tr class="row-odd"><td>251</td>
<td>This endpoint has been retired and should not be used.</td>
<td>Corresponds to a HTTP request to a retired URL.</td>
</tr><tr class="row-even"><td>261</td>
<td>Application cannot perform write actions.</td>
<td>Corresponds with HTTP 403. Thrown when the application is restricted from POST, PUT, or DELETE actions. Check the information on your application dashboard. See <a class="reference external" href="https://support.twitter.com/articles/72585" target="_blank">How to appeal application suspension and other disciplinary actions</a>.</td>
</tr><tr class="row-odd"><td>271</td>
<td>You can’t mute yourself.</td>
<td>Corresponds with HTTP 403. The authenticated user account cannot mute itself.</td>
</tr><tr class="row-even"><td>272</td>
<td>You are not muting the specified user.</td>
<td>Corresponds with HTTP 403. The authenticated user account is not muting the account a call is attempting to unmute.</td>
</tr><tr class="row-odd"><td>323</td>
<td>Animated GIFs are not allowed when uploading multiple images.</td>
<td>Corresponds with HTTP 400. Only one animated GIF is allowed to be attached to a single Tweet.</td>
</tr><tr class="row-even"><td>324</td>
<td>The validation of media ids failed.</td>
<td>Corresponds with HTTP 400. There was a problem with the media ID submitted with the Tweet.</td>
</tr><tr class="row-odd"><td>325</td>
<td>A media id was not found.</td>
<td>Corresponds with HTTP 400. The media ID attached to the Tweet was not found.</td>
</tr><tr class="row-even"><td>326</td>
<td>To protect our users from spam and other malicious activity, this account is temporarily locked.</td>
<td>Corresponds with HTTP 403. The user should log in to <a class="reference external" href="https://twitter.com" target="_blank">https://twitter.com</a> to unlock their account before the user token can be used.</td>
</tr><tr><td>327</td>
<td>You have already retweeted this Tweet.<br>
</td>
<td>Corresponds with HTTP 403. The user cannot retweet the same Tweet more than once.&nbsp;<br>
</td>
</tr><tr class="row-odd"><td>354</td>
<td>The text of your direct message is over the max character limit.</td>
<td>Corresponds with HTTP 403. The message size exceeds the number of characters permitted in a Direct Message.</td>
</tr><tr class="row-even"><td>385</td>
<td>You attempted to reply to a Tweet that is deleted or not visible to you.</td>
<td>Corresponds with HTTP 403. A reply can only be sent with reference to an existing public Tweet.</td>
</tr><tr class="row-odd"><td>386</td>
<td>The Tweet exceeds the number of allowed attachment types.</td>
<td>Corresponds with HTTP 403. A Tweet is limited to a single attachment resource (media, Quote Tweet, etc.)</td>
</tr></tbody></table>
"""
df = pd.read_html(table)[0]
print(df.head()) #Let's just see what this looks like
redshift.load_dataframe(df, 'twitter_error_codes') #load it into Redshift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment