Last active
August 19, 2016 21:09
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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