dev-master
9999999-dev https://github.com/ImpactSeo/killduplicate-api-phpPHP Example Library to use KillDuplicate API
MIT
The Requires
- php >=5.3.0
by Hugo Maugey
content duplicate
PHP Example Library to use KillDuplicate API
PHP Example Library to use KillDuplicate API, (*1)
composer require impact-seo/killduplicate-api-php=dev-master
or download and uncompress archive, (*2)
GET /api/public/credits/api_key
Params, (*3)
api_key = Your Private API Key # required
Returns, (*4)
credits
POST /api/public/price
Params, (*5)
api_key = Your Private API Key # required text = Your Text (UTF-8 encoded) # required
POST /api/public/scan
Params, (*6)
api_key = Your Private API Key # required text = Your Text (UTF-8 encoded) # required exclude_domains = Array of excluded domain names from duplicate search # optional callback = Your callback url # required format = desired return format # optional - possible values : json|xml - default : json
Returns Immediate response, (*7)
text_id : store this id for retrieving result in callback credits : how much credits this scan has cost
Callback Response, (*8)
{ "id": "82", "resume": "Demain, d\u00e8s l'aube, \u00e0 l'heure o\u00f9 blanchit la ca", "filename": null, "credits": "1", "date": "2016-04-01 16:41:43", "callback": "http:\/\/www.your-website.com\/vendor\/impact-seo\/killduplicate-api-php\/api_callback.php", "format": "json", "result": "long", "duplicate": "0", "dup_percentage": "0", "text": null, "exclude_domains": {}, "search_dupes": { "1692": { "id": "1692", "text_id": "82", "phrase": "Demain, d\u00e8s l'aube, \u00e0 l'heure o\u00f9 blanchit la", "search_dupe_results": [] }, ... }, "search_dupe_results": [], "phrases_to_check": "11", "phrases_checked": 11, "results": [] }
If for some reason, previous callback function is not send from our servers or not received by yours, you can force a call to retrieve specific scan status. To know if a scan has finished, you have to compare phrases_to_check against phrases_checked parameters. We stongly advise you to set up a callback function and use this call only to retrieve lost results., (*9)
GET /api/public/scan/API_KEY/SCAN_ID
Params, (*10)
API_KEY = Your Private API Key # required SCAN_ID = Your scan id # required
Returns Immediate response similar to callback response, (*11)
Possible error messages, (*12)
UNKWONW_API_KEY : check your API key is corectly set in config.php ([Get your API Key](https://www.killduplicate.com/en/user/api)) UNAUTHORIZED_IP : check IP where script is run from is added to whitelist ([Chech Authorized IPs](https://www.killduplicate.com/en/user/api)) TOO_MANY_REQUESTS : only one request per second is allowed NO_MORE_CREDITS : you dont' have enough credits to run this scan EMPTY_TEXT_AND_URL : neither text nor url were provided INTERNAL_ERROR : internal server error (please contact admin) UNKNOWN_FORMAT : can only be json|xml INVALID_CALLBACK_URL : invalid callback URL
All texts MUST be encoded in VALID UTF-8. If you load some old Microsoft Words Documents you might have invalid UTF-8 characters like strange quotes. To be sure you have valid UTF-8 encoded texts you can check it :, (*13)
$validUTF8 = ! (false === mb_detect_encoding($text, 'UTF-8', true));
If your text has invalid UTF-8 characters, you can use some home made functions to convert invalid encoding (problem is that some characters in some encodings can be converted into multiple UTF-8 characters you have to unilateraly decide to which character it will be converted to ... and that's why it's your responsability to make UTF-8 conversion when you use API) : Gist Clean UTF-8, or you can make you own., (*14)
Your texts MUST be send WITHOUT HTML entities (You can use PHP function html_entity_decode), (*15)
Be sure your callback is reachable over the network., (*16)
For file permission issues (replace www-data by your webserver username), (*17)
chown -R www-data:www-data vendor/impact-seo/killduplicate-api-php/results chmod -R 775 vendor/impact-seo/killduplicate-api-php/results
PHP Example Library to use KillDuplicate API
MIT
content duplicate