You'll want to research reverse geocoding APIs (such as this one) to turn the coordinates back to an address (which most directions based routing APIs like to have) as well as routing APIs (such as this driving directions API).
As far as making all of the requests and utilizing these APIs - you can perform these tasks using php and cURL.