Sunday, November 11, 2018

Google Maps API - Resolving maps.googleapis.com

I am using the Google Maps API for several websites that retrieve the Lat/Long of an address.


  • Executing the API Call from PHP was NOT working
  • API Key was setup correctly
  • Curl or WGET from Windows is working correctly
  • Get from the browser is working ok
  • WGET/CURL from the command line on CentOS 7 was NOT working ok.
HEre is the output from when I did WGET for the Google Maps API Call:


Resolving maps.googleapis.com (maps.googleapis.com)... 2607:f8b0:4000:816::200a, 216.58.194.106, 216.58.194.138, ...
Connecting to maps.googleapis.com (maps.googleapis.com)|2607:f8b0:4000:816::200a|:443... failed: Connection timed out.
Connecting to maps.googleapis.com (maps.googleapis.com)|216.58.194.106|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]


I could tell it was using IPv6 and the request was timing out. After much Googling I found that others were having the same issue and the resolution was to not use IPv6 for the call. I disabled IPv6 on the machine in question and then the API call worked just fine.

Thank to the following Unixmen Article: https://www.unixmen.com/disable-ipv6-centos-7/


Moving forward, 
  • I need to make sure that IPV6 is not disabled globally for the entire machine. Would be nice if it wasn't.
  • Add this to some checklist somewhere that when I need to use the Google Maps API, I check for this

Full disclosure, I had this working fine on a different CentOS 7 machine and had forgotten how I fixed it for the first 1 hour of research. Then I remembered that it was an "Iptables or Firewall problem". Nope. Then after another hour of research and comparing output on the 2 machines I realized it was due to IPv6. Then I decided to blog about it because I knew I had blogged about it before, but apparently really only thought of blogging about it. Duh!

I hope I can find this blog the next time I need it. :)


Saturday, January 20, 2018

Using Python to access your Trello Boards



Here is a really basic tutorial on using Python to set up and start accessing your Trello boards.

This works with Python 2.7!

First, let's start with installing the python package used to easily access the Trello API:

pip install py-trello

Next, You will need an APPKEY and a Token.
To get your App Key, go to https://trello.com/app-key  and find your App Key. Copy that.
Next, you will need your Token. Click the "Token" and authorize until you receive the following message:

There is your token!

Next, get your Board ID! When you are in Trello, open your Board. The URL will be something like "https://trello.com/b/{HERE IS YOUR BOARD ID}/{THE NAME OF YOUR BOARD}"

Add those pieces of information to a Python file called "myconfig.py"
# myconfig.py:

APPKEY = 'PASTE YOUR API KEY HERE'
TOKEN = 'PASTE YOUR TOKEN HERE'
BOARD_ID = 'PASTE YOUR BOARD ID HERE'


In a different file (e.g., test.py), enter the following code:

from myconfig import *
from trello import TrelloClient


client = TrelloClient(
 api_key=APPKEY,
 api_secret=TOKEN
)

my_board = client.get_board(BOARD_ID)
print my_board.name


Why are we using myconfig.py? This allows us to share our programs without sharing our API Key, Token, and Board Id.

Now when you run this simple example, you will connect to Trello and the program will print out the name of your board. Pretty simple, but once you get here and have the connection working, then the rest will come much easier.