Hi Ali,
What you've described is actually pretty easy to do. You need to use the Google Documents List Data API (DocsList API.) This API is used to create (upload), retrieve, update, and delete documents in Google Docs.
Specifically, since you're using PHP, you'll want to use the PHP client library for the DocsList API. This is documented here. Make sure to read the Getting Started portion of that document, as it enumerates important steps on setting up the Zend Framework, with which the DocsList PHP client library comes bundled.
Assuming you're creating word processing docs (as opposed to spreadsheets or presentations,) the code you need to upload a document is straight forward.
// Use ClientLogin to authenticate to Google Docs
$username = '[email protected]';
$password = 'myPassword';
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $password,
$service);
$docs = new Zend_Gdata_Docs($httpClient);
// Actually upload the file, the second parameter here is the document title
$newDocumentEntry = $docs->uploadFile('test.txt', 'order-123456',
'text/plain', Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
You mentioned you'd also like to store references to these documents in your system. To do this, simply give each document a unique title (something like "order-123456".)
Next, to fetch the stored documents, use the following code:
$docsQuery = new Zend_Gdata_Docs_Query();
$docsQuery->setTitle("order-123456");
$docsQuery->setTitleExact(true);
$feed = $docs->getDocumentListFeed($docsQuery);
foreach ($feed->entries as $entry) {
// ... every $entry is an individual document found in the search ...
}
Note that this example uses ClientLogin, which requires a raw username and password. A better, but less simple way to authenticate is to use OAuth/AuthSub. Also note that the PHP client library is only updated for version 1.0 of the DocsList API at the moment, which is deprecated. There should be an updated release of the client library soon to support newer versions of the API. For more information, see the Google Documents List Data API Developer's Guide. Good luck!