{"id":32736,"date":"2020-05-24T14:08:57","date_gmt":"2020-05-24T13:08:57","guid":{"rendered":"https:\/\/www.aware-online.com\/?p=32736"},"modified":"2020-05-24T16:26:02","modified_gmt":"2020-05-24T15:26:02","slug":"email-to-flickr-account-part2","status":"publish","type":"post","link":"https:\/\/www.aware-online.com\/en\/email-to-flickr-account-part2\/","title":{"rendered":"Email to Flickr-account #2"},"content":{"rendered":"
This query uses the public API key<\/strong> “3aac009af063175e4bb3623f9d3c557b<\/em>” from Flickr.<\/span> In our previous blog post, we already indicated that this API key probably cannot be used indefinitely.<\/span> This is correct, because when you run the above query you will see the error message below.<\/span> In this error message, you will see the error code 100, followed by the message “Invalid API Key (Key not found)<\/em>“.<\/span> Thus, Flickr’s public API key no longer works.<\/span><\/span><\/p>\n <\/p>\n The API key that we used on April 23, 2020, unfortunately no longer works today.<\/span> If you use public API keys, you will often find that an API key no longer works at some point.<\/span> The usability can stop in different ways: for example, a key may no longer be valid after a x number of uses<\/strong>, or for example because the usability stops after a certain period of time<\/strong>.<\/span><\/span><\/p>\n Twitter user @OsintSupport<\/a> (check out his awesome Chrome extensions<\/a>!) has informed us that the public API key is replaced every 8 hours<\/strong> with a new API key.<\/span> This means that the key is valid for about 8 hours.<\/span> Moreover, the use of the API key would not be blocked on the basis of repeated use by a single user: the API key can therefore be used for many thousands of requests from the same IP address<\/strong>.<\/span> And that makes the use of the API request interesting to automate.<\/span><\/span><\/p>\n <\/p>\n The so-called Requests library<\/strong> that allows you to send HTTP requests is an example of a code that is not included by default in Python.<\/span> You must therefore install this library before you can use it.<\/span> This can be done as follows.<\/span><\/span><\/p>\n <\/p>\n <\/p>\n We use the following code to print the content<\/strong> of the web page in text form. <\/p>\n <\/em><\/p>\n *: in our example, the Python script is stored on the desktop.<\/span> With the command “cd” (change directory) we opened the folder “Desktop”.<\/span> If your script is stored in a different folder, first navigate to this folder.<\/span><\/span><\/em><\/p>\nExpiration of an API key<\/h2>\n
Automate your searches<\/h2>\n
Get started with Python<\/h2>\n
Step 1: download and installation of Python<\/h3>\n
\n<\/p>\n
\n<\/p>\n
\n<\/p>\nStep 2: Download Notepad++<\/h3>\n
\n<\/p>\n
\n<\/p>\n
<\/p>\nStep 3: Download the Request-library<\/h3>\n
<\/p>\n
\nPip install requests<\/code><\/p>\n
\n<\/p>\n
\npython -m pip install --upgrade pip<\/code><\/p>\n
Step 4: Import the Requests-library<\/h3>\n
\nimport requests<\/code><\/p>\n
<\/h3>\n
Step 5: Define the URL<\/h3>\n
\nhttps:\/\/www.flickr.com\/services\/rest\/?method=flickr.people.findByEmail&api_key=3aac009af063175e4bb3623f9d3c557b<\/strong>&find_email=davidjones%40yahoo.com&format=rest<\/em>
\nHowever, because the API key of this query turned out to be no longer valid, we have a new query below that will make the request work again.<\/span> If you want to do this yourself, you will have to use Flickr’s public API key again or obtain a private key yourself.
\nhttps:\/\/www.flickr.com\/services\/rest\/?method=flickr.people.findByEmail&api_key=f402aa5bec41484e322830c07b853ddc<\/strong>&find_email=davidjones%40yahoo.com&format=rest<\/em><\/p>\n
\nurl = 'https:\/\/www.flickr.com\/services\/rest\/?method=flickr.people.findByEmail&api_key=b51834379b8a3b68db81bf2ea953a03e&find_email=davidjones%40yahoo.com&format=rest'<\/code><\/p>\n
Step 6: Run the request and save the response in a variable<\/h3>\n
\n#request uitvoeren en uitkomst in een variabele opslaan<\/code>
\nresponse = requests.get(url)<\/code><\/p>\n
<\/h3>\n
Step 7: Print the result<\/h3>\n
\n#het resultaat printen (statuscode)<\/code>
\nprint(response)<\/code><\/p>\n
\n#het resultaat printen (tekst)
\nprint(response.text)<\/code><\/p>\nStep 8: Run the Python-script<\/h2>\n
<\/p>\n\n
Step 9: check out the results<\/h2>\n