@@ -47,18 +47,16 @@ Please refer to the official:
47
47
## Installation
48
48
49
49
1 . You can install the package via composer:
50
-
51
- ``` bash
52
- composer require sharpapi/sharpapi-php-client
53
- ```
54
-
50
+ ``` bash
51
+ composer require sharpapi/sharpapi-php-client
52
+ ```
55
53
2. Register at [SharpApi.com](https://sharpapi.com/) and get the API key.
56
-
57
54
** That' s it!**
58
55
59
56
## Usage
60
57
61
58
### Simple example
59
+
62
60
```php
63
61
$sharpApi = new \SharpAPI\SharpApiService\SharpApiService(' 8bKzQl3cwckfVsnsN8T8p4BsACkziEQJ72U4pXpQ' );
64
62
@@ -68,11 +66,12 @@ $resultSharpApiJob = $sharpApi->pollJobStatusAndFetchResults($statusUrl);
68
66
69
67
var_dump($resultSharpApiJob ->getResultJson());
70
68
` ` `
69
+
71
70
Typical use case require these steps:
72
71
73
72
1. Dispatch one of the available AI processing methods (this will return job processing status URL)
74
73
2. Run ` pollJobStatusAndFetchResults($statusUrl )` method which operates in polling mode, sending underneath
75
- requests every 10 seconds for 180 seconds (these values can be customized,
74
+ requests every 10 seconds for 180 seconds (these values can be customized,
76
75
check ` SharpApiService` source code).
77
76
3. ` SharpApiJob` object will be returned.
78
77
4. For a job finished with ` success` return status you can obtain the results with one
@@ -95,6 +94,7 @@ As long as the job is still being processed by our engine it will keep
95
94
returning `pending` status.
96
95
97
96
### Guzzle Exceptions
97
+
98
98
Underlying HTTP requests are powered with Guzzle,
99
99
so it' s a good idea to check for
100
100
typical [Guzzle Exceptions](https://docs.guzzlephp.org/en/stable/quickstart.html#exceptions):
@@ -105,7 +105,7 @@ use GuzzleHttp\Exception\ClientException;
105
105
// Step 1: dispatch the job to the API with one of the methods, for example:
106
106
try {
107
107
$statusUrl = \S harpApiService::summarizeText($text , ' German' );
108
- // $statusUrl example value: 'http ://sharpapi.com/api/v1/job/status/75acb6dc-a975-4969-9ef1-c62cebc511cb'
108
+ // $statusUrl example value: ' https ://sharpapi.com/api/v1/job/status/75acb6dc-a975-4969-9ef1-c62cebc511cb'
109
109
} catch (ClientException $e ) {
110
110
// $e->getResponse ()
111
111
}
@@ -121,7 +121,6 @@ $jobResultArray = $jobResult->getResultArray();
121
121
$jobResultObject = $jobResult->getResultObject ();
122
122
` ` `
123
123
124
-
125
124
### Framework Controller usage example
126
125
127
126
` ` ` php
@@ -173,7 +172,10 @@ Each method always returns `SharpApiJob` object, where its
173
172
` getResultJson / getResultArray / getResultObject`
174
173
methods will return different data structure.
175
174
Please refer to the detailed examples provided
176
- at [ SharpAPI.com] ( https://sharpapi.com/ )
175
+ at [SharpAPI.com](https://sharpapi.com/).
176
+
177
+ For methods that have language parameter you can also
178
+ use ` SharpApiLanguages` Enum values to make your code more readable.
177
179
178
180
### HR
179
181
@@ -241,7 +243,7 @@ Parses the customer's product review and provides its sentiment (POSITIVE/NEGATI
241
243
with a score between 0-100%. Great for sentiment report processing for any online store.
242
244
243
245
```php
244
- $statusUrl = \SharpApiService::productReviewSentiment('review contents', 'English' );
246
+ $statusUrl = \SharpApiService::productReviewSentiment(' review contents' );
245
247
```
246
248
247
249
#### Product Categories
@@ -347,7 +349,7 @@ Parses the Travel/Hospitality product review and provides its sentiment
347
349
Great for sentiment report processing for any online store.
348
350
349
351
` ` ` php
350
- $statusUrl = \SharpApiService::travelReviewSentiment($text, 'English' );
352
+ $statusUrl = \S harpApiService::travelReviewSentiment($text );
351
353
` ` `
352
354
353
355
# ### Tours & Activities Product Categories
0 commit comments