File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+ import requests
3+
4+ """
5+
6+ 1. pip install requests
7+ 2. Obtain an API key: https://www.fullcontact.com/developer/pricing/
8+
9+ Example usage:
10+
11+ $ python 30_fullcontact.py email SOME@EMAIL.COM
12+ $ python 30_fullcontact.py twitter TWITTER_HANDLE
13+ """
14+
15+
16+ # constants
17+
18+ API_KEY = 'GET YOUR OWN'
19+ BASE_URL = 'http://api.fullcontact.com/v2/person.json'
20+
21+
22+ # helpers
23+
24+ def get_arguments ():
25+ if len (sys .argv ) is 3 :
26+ return {
27+ 'media' : sys .argv [1 ],
28+ 'user_info' : sys .argv [2 ]
29+ }
30+ else :
31+ print ('Specify at least 1 argument' )
32+ sys .exit ()
33+
34+
35+ def call_api (contact ):
36+ url = BASE_URL + '?{0}={1}&apiKey={2}' .format (
37+ contact ['media' ], contact ['user_info' ], API_KEY )
38+ r = requests .get (url )
39+ if r .status_code == 200 :
40+ return r .text
41+ else :
42+ return "Sorry, no results found."
43+
44+
45+ # main
46+
47+ if __name__ == "__main__" :
48+ media = get_arguments ()
49+ print (call_api (media ))
Original file line number Diff line number Diff line change 29291 . ** 27_send_sms.py** : Send SMS message via [ TextBelt] ( http://textbelt.com/ )
30301 . ** 28_income_tax_calculator.py** : Income tax calculator via [ Taxee] ( http://taxee.io/ )
31311 . ** 29_json_to_yaml.py** : Convert JSON to YAML
32+ 1 . ** 30_fullcontact.py** : Call the [ FullcContact] ( https://www.fullcontact.com/developer/ ) API
You can’t perform that action at this time.
0 commit comments