Welcome to marom.dev

My name is Mike Marom and this is where I host some of my sample code and small learning projects. If you're not interested in those, you may find what you're looking for at marom.net

Simple REST Client:

A few simple code examples of how to make REST API calls:
- /php-rest-api-client/get-zipcode.php makes a REST GET call to zippopotam.us's open zipcode lookup REST API, to retrieve zipcode information.
- /php-rest-api-client/get-account.php makes a REST GET call to the php-rest-api-server (see below) REST API, to retrieve a specific account.
- /php-rest-api-client/get-all-accounts.php makes a REST GET call to the php-rest-api-server (see below) REST API, without a specific account listed.
- /php-rest-api-client/post-account.php makes a REST POST call to the php-rest-api-server (see below) REST API, to add a new account.

This code is at GitHub repo php-rest-api-client

Simple REST Server:

A basic implementation of a REST API server, without authentication. Uses mock account data to respond to requests.
REST API endpoint: /php-rest-api-server/account/
Supported REST methods:
- GET /account/ - retrieves all accounts
- GET /account/{id} - retrieves account with id={id}
- POST /account/ - creates new account, automatically assigns new ID
- PUT /account/ - creates / updates acccount
- DELETE /account/{id} - deletes account with id={id}

This code is at GitHub repo php-rest-api-server

User login (direct & with Google):

A basic implementation of two ways to log in users: directly (account created on the webapp), and by utilizing Google's Sign-In OAuth2 system.
To see this in action: /php-signin-with-google
For direct login, the sample code has an array of pre-created users that the login system checks against. This would be replaced by the database username lookup in a real world implementation. If the user is found (email + password match) the webapp informs the user of a successful login. Passwords aren't stored on server, they are hashed using MD5 and checked against hash.
For Google login, this webapp utilizes the Google API Client for PHP (PHP v7.4) to generate a login URL and to parse the results.
Future enhancements to this code: create sign-in screen, store users in database, allow for password reset

This code is at GitHub repo php-signin-with-google

Retrieving structured data from ChatGPT:

A demonstration of how chatGPT can retrieve structured data in a way that is easy to parse and populate into a database table.
To see this in action: /populate-currencies-database
The script creates a brand new table, queries chatGPT's open API for information about countries and their currencies, and then uses that data to populate the table.

This code is at GitHub repo php-chatGPT-currencies-DB

Basic REST API call implementation in JavaScript:

A simple JS call to construct, send and parse a basic GET request to a public REST API, looking up Cryprocurrency valuations.
To see this in action: /js-rest-client
There are multiple ways to generate a REST API call in Javascript. This script utilizes no 3rd party libraries, instead relying on the XMLHttpRequest APIs to generate the call. This script needs to be run in a browser, since Node.js does not support XMLHttpRequest.

This code is at GitHub repo js-rest-api-client