FAQ: A Watson-Powered Application - A Working App: Celebrity Match

This community-built FAQ covers the “A Working App: Celebrity Match” exercise from the lesson “A Watson-Powered Application”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn the Watson API

FAQs on the exercise A Working App: Celebrity Match

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I can’t go trough this exercise because this link:

https://www.codecademy.com/courses/ruby-intermediate-en-rUwFe/0/1?curriculum_id=5122d5f811fbdb5456005922

don’t work for me so I don’t have twitter API credentials.

Can somebody point me to the correct link?

5 Likes

And the link still isnt working - did you find another way to solve this

1 Like

As previously noted, this exercise requires getting our Twitter User API settings. The process for how to get API settings is supposed to be at this embedded link: https://www.codecademy.com/catalog/subject/all
but that link is to Codeacademy course catalog. When I attempt to get the answers from the Twitter Developer discussions, nothing I found fits this code.
Disappointing since this seems like a fun exercise.

Having the same issue. Wish they would read this and resolve it.

I figured out the Twitter API, but then there’s an issue with the Watson API:

CelebrityMatchDemo.py:36: DeprecationWarning: watson-developer-cloud moved to ibm-watson. To get updates, use the new package.

what’s the process to get the twitter API to work? Errors I get are below …

File “CelebrityMatchDemo.py”, line 75, in
user_result = analyze(user_handle)
File “CelebrityMatchDemo.py”, line 27, in analyze
statuses = twitter_api.GetUserTimeline(screen_name=handle, count=200, include_rts=False)
File “/usr/local/lib/python2.7/dist-packages/twitter/api.py”, line 812, in GetUserTimeline
data = self._ParseAndCheckTwitter(resp.content.decode(‘utf-8’))
File “/usr/local/lib/python2.7/dist-packages/twitter/api.py”, line 4908, in _ParseAndCheckTwitter
self._CheckForTwitterError(data)
File “/usr/local/lib/python2.7/dist-packages/twitter/api.py”, line 4928, in _CheckForTwitterError
raise TwitterError(data[‘errors’])
twitter.error.TwitterError: [{u’message’: u’Bad Authentication data.’, u’code’: 215}]

1 Like

I think you need to make a Twitter Developer account before you’re even able to get Twitter API credentials. Twitter needs to approve your account first as well, but it should be pretty quick.

Here is the link on how to get started: https://developer.twitter.com/en/docs/labs/filtered-stream/quick-start.

Good luck! :muscle:t3:

No matter what you do, this will never work because you will get a credentials error, and that is not because your credentials are wrong but because IBM changed the URL from the one hardcoded in the PersonalityInsights class:

default_url = 'https://gateway.watsonplatform.net/personality-insights/api'

to the new URL:

https://api.<REGION>.personality-insights.watson.cloud.ibm.com/instances/<YOUR_INSTANCE>

There is no way to escape this unless codecademy installs an updated package. So my final working solution is to directly use CURL (a terminal command) from python, and ditch the PersonalityInsights class completely. The recommended way to do this according to IBM is to write to a file and then use the --data-binary option, so we will have to write the contents of the text variable in a file first:

import os

with open('profile.txt', 'w') as f:
    f.write(text)

pi_api_key = 'YOUR BLUEMIX API KEY'
pi_url = 'YOUR BLUEMIX URL'
curl_command = "curl -X POST -u 'apikey:" + pi_api_key + "' --header 'Content-Type: text/plain;charset=utf-8' --header 'Accept: application/json' --data-binary @profile.txt '" + pi_url + "'"

pi_result = os.popen(curl_command).read()

The only issue is that Codecademy also does not have curl available in the provided terminal, but at least this should work if you download the script to your laptop, install all python dependencies and run it in your own terminal.

Another (better) solution is for Codecademy to update the tutorial, of course.