Refer to using_curl.php file. Prerequisites: create connected app in SF and keep handy client id and secret. You also need your self-domain on SFDC e.g. my self domain is https://anil99-dev-ed.my.salesforce.com Rest of the steps are self-explanatory in source code.
Refer to using_connected_app.php file. Prerequisites: create connected app in SF and keep handy client id and secret. Rest of the steps are self-explanatory in source code.