Skip to content

Instantly share code, notes, and snippets.

@grasmash
Last active August 19, 2016 21:09
Show Gist options
  • Save grasmash/f8d86591919887655569 to your computer and use it in GitHub Desktop.
Save grasmash/f8d86591919887655569 to your computer and use it in GitHub Desktop.
Example of implementing USASearch's PHP SDK to create a new document in the USASearch index.
<?php
// Set up variables.
$document = create_dummy_document();
$username = 'test_index';
$password = 'test_key';
// Create document in USASearch Index.
$client = new UsaSearchClient($affiliate, $password);
$response = $client->createDocument($document);
function create_dummy_document() {
$document = new UsaSearchDocument();
$document->setDocumentId(1);
$document->setTitle('Test Title');
$document->setContent('<p>Hello world!</p>');
$document->setPath('https://www.example.com/test-document');
$document->setCreated(date('c'));
$document->setPromote(1);
return $document;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment