<?php
/**
* @author Eric Sizemore <admin@secondversion.com>
* @package Search Keywords
* @version 2.0.0
* @copyright 2006 - 2017 Eric Sizemore
* @license GNU GPL v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Example;
/*
* Honestly, there is not much to using this class. It is very simple and does
* not take much to get going. You really only need to do the following:
*/
// First include the class file.
require_once('./Keywords.php');
// Next, instantiate the object using it's "getInstance()" function
$keys = \Esi\Search\Keywords::getInstance();
// Everything else is pretty much handled for you automatically.
// Calling 'getKeys()' will automatically parse the referrer for you.
$keys = $keys->getKeys();
/*
* The 'getKeys()' call will return an array with the following structure:
*
* array(3) {
* [0] => 'referrer url',
* [1] => 'keyword',
* [2] => 'search engine'
* }
*
* For example:
*
* array(3) {
* [0]=> string(160) "https://search.yahoo.com/search;_ylc=X3oDMTFiN25laTRvBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2h3ZWI-?p=test&fr=yfp-t&fp=1&toggle=1&cop=mss&ei=UTF-8"
* [1]=> string(4) "test"
* [2]=> string(5) "Yahoo"
* }
*/
if (count($keys)) {
echo "Referring URL: $keys[0]<br />Keywords: $keys[1]<br />Search Engine: $keys[2]";
}
/*
* The above will output something similar to:
*
* Referring URL: https://search.yahoo.com/search;_ylc=X3oDMTFiN25laTRvBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2h3ZWI-?p=test&fr=yfp-t&fp=1&toggle=1&cop=mss&ei=UTF-8
* Keywords: test
* Search Engine: Yahoo
*/
// And honestly, that's really all there is to it.
|