@@ -16,18 +16,27 @@ void Start()
16
16
}
17
17
```
18
18
19
+ ### Fail handler
20
+ These examples use a common fail handler.
21
+ ``` cs
22
+ private void OnFail (RESTConnector .Error error , Dictionary < string , object > customData )
23
+ {
24
+ Log .Error (" ExampleAlchemyLanguage.OnFail()" , " Error received: {0}" , error .ToString ());
25
+ }
26
+ ```
27
+
19
28
### Get Authors
20
29
You can extract Authors from a URL or HTML source.
21
30
``` cs
22
31
private void GetAuthors ()
23
32
{
24
- if (! _alchemyApi .GetAuthors (OnGetAuthors , < url - or - htmlpage > ))
33
+ if (! _alchemyApi .GetAuthors (OnGetAuthors , OnFail , < url - or - htmlpage > ))
25
34
Log .Debug (" ExampleAlchemyLanguage.GetAuthors()" , " Failed to get authors" );
26
35
}
27
36
28
- private void OnGetAuthors (AuthorsData authors , string data )
37
+ private void OnGetAuthors (AuthorsData authors , Dictionary < string , object > customData )
29
38
{
30
- Log .Debug (" ExampleAlchemyLanguage.OnGetAuthors()" , " Alchemy Language - Get authors response html: {0}" , data );
39
+ Log .Debug (" ExampleAlchemyLanguage.OnGetAuthors()" , " Alchemy Language - Get authors response html: {0}" , customData [ " json " ]. ToString () );
31
40
}
32
41
```
33
42
@@ -36,13 +45,13 @@ You can get Concepts from a URL, HTML or Text source.
36
45
``` cs
37
46
private void GetRankedConcepts ()
38
47
{
39
- if (! _alchemyApi .GetRankedConcepts (OnGetConcepts , < text - or - url - or - htmlpage > ))
48
+ if (! _alchemyApi .GetRankedConcepts (OnGetConcepts , OnFail , < text - or - url - or - htmlpage > ))
40
49
Log .Debug (" ExampleAlchemyLanguage.GetRankedConcepts()" , " Failed to get concepts" );
41
50
}
42
51
43
- private void OnGetConcepts (ConceptsData concepts , string data )
52
+ private void OnGetConcepts (ConceptsData concepts , Dictionary < string , object > customData )
44
53
{
45
- Log .Debug (" ExampleAlchemyLanguage.OnGetConcepts()" , " Alchemy Language - Get ranked concepts response text: {0}" , data );
54
+ Log .Debug (" ExampleAlchemyLanguage.OnGetConcepts()" , " Alchemy Language - Get ranked concepts response text: {0}" , customData [ " json " ]. ToString () );
46
55
}
47
56
```
48
57
@@ -51,13 +60,13 @@ You can extract Dates from a URL, HTML or Text source.
51
60
``` cs
52
61
private void GetRankedConcepts ()
53
62
{
54
- if (! _alchemyApi .GetDates (OnGetConcepts , < text - or - url - or - htmlpage > ))
63
+ if (! _alchemyApi .GetDates (OnGetConcepts , OnFail , < text - or - url - or - htmlpage > ))
55
64
Log .Debug (" ExampleAlchemyLanguage.GetRankedConcepts()" , " Failed to get concepts" );
56
65
}
57
66
58
- private void OnGetDates (DateData dates , string data )
67
+ private void OnGetDates (DateData dates , Dictionary < string , object > customData )
59
68
{
60
- Log .Debug (" ExampleAlchemyLanguage.OnGetDates()" , " Alchemy Language - Get dates response html: {0}" , data );
69
+ Log .Debug (" ExampleAlchemyLanguage.OnGetDates()" , " Alchemy Language - Get dates response html: {0}" , customData [ " json " ]. ToString () );
61
70
}
62
71
```
63
72
@@ -66,13 +75,13 @@ You can get Emotions from a URL, HTML or Text source.
66
75
``` cs
67
76
private void GetEmotions ()
68
77
{
69
- if (! _alchemyApi .GetEmotions (OnGetEmotions , < text - or - url - or - htmlpage > ))
78
+ if (! _alchemyApi .GetEmotions (OnGetEmotions , OnFail , < text - or - url - or - htmlpage > ))
70
79
Log .Debug (" ExampleAlchemyLanguage.GetEmotions()" , " Failed to get emotions" );
71
80
}
72
81
73
- private void OnGetEmotions (EmotionData emotions , string data )
82
+ private void OnGetEmotions (EmotionData emotions , Dictionary < string , object > customData )
74
83
{
75
- Log .Debug (" ExampleAlchemyLanguage.OnGetEmotions()" , " Alchemy Language - Get emotions response html: {0}" , data );
84
+ Log .Debug (" ExampleAlchemyLanguage.OnGetEmotions()" , " Alchemy Language - Get emotions response html: {0}" , customData [ " json " ]. ToString () );
76
85
}
77
86
```
78
87
@@ -81,13 +90,13 @@ You can extract Entities from a URL, HTML or Text source.
81
90
``` cs
82
91
private void ExtractEntities ()
83
92
{
84
- if (! _alchemyApi .ExtractEntities (OnExtractEntities , < text - or - url - or - htmlpage > ))
93
+ if (! _alchemyApi .ExtractEntities (OnExtractEntities , OnFail , < text - or - url - or - htmlpage > ))
85
94
Log .Debug (" ExampleAlchemyLanguage.ExtractEntities()" , " Failed to get emotions" );
86
95
}
87
96
88
- private void OnExtractEntities (EntityData entityData , string data )
97
+ private void OnExtractEntities (EntityData entityData , Dictionary < string , object > customData )
89
98
{
90
- Log .Debug (" ExampleAlchemyLanguage.OnExtractEntities()" , " Alchemy Language - Extract entities response html: {0}" , data );
99
+ Log .Debug (" ExampleAlchemyLanguage.OnExtractEntities()" , " Alchemy Language - Extract entities response html: {0}" , customData [ " json " ]. ToString () );
91
100
}
92
101
```
93
102
@@ -96,13 +105,13 @@ You can detect RSS Feeds from a URL source.
96
105
``` cs
97
106
private void GetFeeds ()
98
107
{
99
- if (! m_AlchemyLanguage .DetectFeeds (OnDetectFeeds , < url - or - htmlpage > ))
108
+ if (! m_AlchemyLanguage .DetectFeeds (OnDetectFeeds , OnFail , < url - or - htmlpage > ))
100
109
Log .Debug (" ExampleAlchemyLanguage.GetFeeds()" , " Failed to get feeds." );
101
110
}
102
111
103
- private void OnDetectFeeds (FeedData feedData , string data )
112
+ private void OnDetectFeeds (FeedData feedData , Dictionary < string , object > customData )
104
113
{
105
- Log .Debug (" ExampleAlchemyLanguage.OnDetectFeeds()" , " Alchemy Language - Detect feeds response url: {0}" , data );
114
+ Log .Debug (" ExampleAlchemyLanguage.OnDetectFeeds()" , " Alchemy Language - Detect feeds response url: {0}" , customData [ " json " ]. ToString () );
106
115
}
107
116
```
108
117
@@ -111,13 +120,13 @@ You can extract Keywords form a URL, HTML or Text source.
111
120
``` cs
112
121
private void GetKeywords ()
113
122
{
114
- if (! m_AlchemyLanguage .ExtractKeywords (OnExtractKeywords , < text - or - url - or - htmlpage > ))
123
+ if (! m_AlchemyLanguage .ExtractKeywords (OnExtractKeywords , OnFail , < text - or - url - or - htmlpage > ))
115
124
Log .Debug (" ExampleAlchemyLanguage.GetKeywords()" , " Failed to get keywords by URL POST" );
116
125
}
117
126
118
- private void OnExtractKeywords (KeywordData keywordData , string data )
127
+ private void OnExtractKeywords (KeywordData keywordData , Dictionary < string , object > customData )
119
128
{
120
- Log .Debug (" ExampleAlchemyLanguage.OnExtractKeywords()" , " Alchemy Language - Extract keywords response html: {0}" , data );
129
+ Log .Debug (" ExampleAlchemyLanguage.OnExtractKeywords()" , " Alchemy Language - Extract keywords response html: {0}" , customData [ " json " ]. ToString () );
121
130
}
122
131
```
123
132
@@ -126,13 +135,13 @@ You can extract the language of a URL, HTML or Text source.
126
135
``` cs
127
136
private void GetLanguages ()
128
137
{
129
- if (! m_AlchemyLanguage .GetLanguages (OnGetLanguages , < text - or - url > ))
138
+ if (! m_AlchemyLanguage .GetLanguages (OnGetLanguages , OnFail , < text - or - url > ))
130
139
Log .Debug (" ExampleAlchemyLanguage.GetLanguages()" , " Failed to get languages" );
131
140
}
132
141
133
- private void OnGetLanguages (LanguageData languages , string data )
142
+ private void OnGetLanguages (LanguageData languages , Dictionary < string , object > customData )
134
143
{
135
- Log .Debug (" ExampleAlchemyLanguage.OnGetLanguages()" , " Alchemy Language - Get languages response html: {0}" , data );
144
+ Log .Debug (" ExampleAlchemyLanguage.OnGetLanguages()" , " Alchemy Language - Get languages response html: {0}" , customData [ " json " ]. ToString () );
136
145
}
137
146
```
138
147
@@ -141,13 +150,13 @@ You can get the Microformat of a URL source.
141
150
``` cs
142
151
private void GetMicroformats ()
143
152
{
144
- if (! m_AlchemyLanguage .GetMicroformats (OnGetMicroformats , < url - or - htmlpage > ))
153
+ if (! m_AlchemyLanguage .GetMicroformats (OnGetMicroformats , OnFail , < url - or - htmlpage > ))
145
154
Log .Debug (" ExampleAlchemyLanguage.GetMicroformats()" , " Failed to get microformats" );
146
155
}
147
156
148
- private void OnGetMicroformats (MicroformatData microformats , string data )
157
+ private void OnGetMicroformats (MicroformatData microformats , Dictionary < string , object > customData )
149
158
{
150
- Log .Debug (" ExampleAlchemyLanguage.OnGetMicroformats()" , " Alchemy Language - Get microformats response url: {0}" , data );
159
+ Log .Debug (" ExampleAlchemyLanguage.OnGetMicroformats()" , " Alchemy Language - Get microformats response url: {0}" , customData [ " json " ]. ToString () );
151
160
}
152
161
```
153
162
@@ -156,13 +165,13 @@ You can extract the publication date from a URL or HTML source.
156
165
``` cs
157
166
private void GetPublicationDate ()
158
167
{
159
- if (! m_AlchemyLanguage .GetPublicationDate (OnGetPublicationDate , < url - or - htmlpage > ))
168
+ if (! m_AlchemyLanguage .GetPublicationDate (OnGetPublicationDate , OnFail , < url - or - htmlpage > ))
160
169
Log .Debug (" ExampleAlchemyLanguage.GetPublicationDate()" , " Failed to get publication dates" );
161
170
}
162
171
163
- private void OnGetPublicationDate (PubDateData pubDates , string data )
172
+ private void OnGetPublicationDate (PubDateData pubDates , Dictionary < string , object > customData )
164
173
{
165
- Log .Debug (" ExampleAlchemyLanguage.OnGetPublicationDate()" , " Alchemy Language - Get publication date response url: {0}" , data );
174
+ Log .Debug (" ExampleAlchemyLanguage.OnGetPublicationDate()" , " Alchemy Language - Get publication date response url: {0}" , customData [ " json " ]. ToString () );
166
175
}
167
176
```
168
177
@@ -171,13 +180,13 @@ You can extract Relations from a URL, HTML or Text source.
171
180
``` cs
172
181
private void GetRelations ()
173
182
{
174
- if (! m_AlchemyLanguage .GetRelations (OnGetRelations , < text - or - url - or - htmlpage > ))
183
+ if (! m_AlchemyLanguage .GetRelations (OnGetRelations , OnFail , < text - or - url - or - htmlpage > ))
175
184
Log .Debug (" ExampleAlchemyLanguage.GetRelations()" , " Failed to get relations" );
176
185
}
177
186
178
- private void OnGetRelations (RelationsData relationsData , string data )
187
+ private void OnGetRelations (RelationsData relationsData , Dictionary < string , object > customData )
179
188
{
180
- Log .Debug (" ExampleAlchemyLanguage.OnGetRelations()" , " Alchemy Language - Get relations response html: {0}" , data );
189
+ Log .Debug (" ExampleAlchemyLanguage.OnGetRelations()" , " Alchemy Language - Get relations response html: {0}" , customData [ " json " ]. ToString () );
181
190
}
182
191
```
183
192
@@ -186,13 +195,13 @@ You can extract the Sentiment from a URL, HTML or Text source.
186
195
``` cs
187
196
private void GetTextSentiment ()
188
197
{
189
- if (! m_AlchemyLanguage .GetTextSentiment (OnGetTextSentiment , < text - or - url - or - htmlpage > ))
198
+ if (! m_AlchemyLanguage .GetTextSentiment (OnGetTextSentiment , OnFail , < text - or - url - or - htmlpage > ))
190
199
Log .Debug (" ExampleAlchemyLanguage.GetTextSentiment()" , " Failed to get sentiment" );
191
200
}
192
201
193
- private void OnGetTextSentiment (SentimentData sentimentData , string data )
202
+ private void OnGetTextSentiment (SentimentData sentimentData , Dictionary < string , object > customData )
194
203
{
195
- Log .Debug (" ExampleAlchemyLanguage.OnGetTextSentiment()" , " Alchemy Language - Get text sentiment response html: {0}" , data );
204
+ Log .Debug (" ExampleAlchemyLanguage.OnGetTextSentiment()" , " Alchemy Language - Get text sentiment response html: {0}" , customData [ " json " ]. ToString () );
196
205
}
197
206
```
198
207
@@ -201,13 +210,13 @@ You can extract a Targeted Sentiment from a URL, HTML or Text source. Targets ar
201
210
``` cs
202
211
private void GetTargetedSentiment ()
203
212
{
204
- if (! m_AlchemyLanguage .GetTargetedSentiment (OnGetTargetedSentiment , < text - or - url - or - htmlpage > , < targets > ))
213
+ if (! m_AlchemyLanguage .GetTargetedSentiment (OnGetTargetedSentiment , OnFail , < text - or - url - or - htmlpage > , < targets > ))
205
214
Log .Debug (" ExampleAlchemyLanguage.GetTargetedSentiment()" , " Failed to get targeted sentiment" );
206
215
}
207
216
208
- private void OnGetTargetedSentiment (TargetedSentimentData sentimentData , string data )
217
+ private void OnGetTargetedSentiment (TargetedSentimentData sentimentData , Dictionary < string , object > customData )
209
218
{
210
- Log .Debug (" ExampleAlchemyLanguage.OnGetTargetedSentiment()" , " Alchemy Language - Get targeted sentiment response html: {0}" , data );
219
+ Log .Debug (" ExampleAlchemyLanguage.OnGetTargetedSentiment()" , " Alchemy Language - Get targeted sentiment response html: {0}" , customData [ " json " ]. ToString () );
211
220
}
212
221
```
213
222
@@ -216,13 +225,13 @@ You can get the Taxonomy of entities from a URL, HTML or Text source.
216
225
``` cs
217
226
private void GetRankedTaxonomy ()
218
227
{
219
- if (! m_AlchemyLanguage .GetRankedTaxonomy (OnGetRankedTaxonomy , < text - or - url - or - htmlpage > ))
228
+ if (! m_AlchemyLanguage .GetRankedTaxonomy (OnGetRankedTaxonomy , OnFail , < text - or - url - or - htmlpage > ))
220
229
Log .Debug (" ExampleAlchemyLanguage.GetRankedTaxonomy()" , " Failed to get ranked taxonomy" );
221
230
}
222
231
223
- private void OnGetRankedTaxonomy (TaxonomyData taxonomyData , string data )
232
+ private void OnGetRankedTaxonomy (TaxonomyData taxonomyData , Dictionary < string , object > customData )
224
233
{
225
- Log .Debug (" ExampleAlchemyLanguage.OnGetRankedTaxonomy()" , " Alchemy Language - Get ranked taxonomy response html: {0}" , data );
234
+ Log .Debug (" ExampleAlchemyLanguage.OnGetRankedTaxonomy()" , " Alchemy Language - Get ranked taxonomy response html: {0}" , customData [ " json " ]. ToString () );
226
235
}
227
236
```
228
237
@@ -231,13 +240,13 @@ You can exctract the Text from a URL or HTML source.
231
240
``` cs
232
241
private void GetText ()
233
242
{
234
- if (! m_AlchemyLanguage .GetText (OnGetText , < url - or - htmlpage > ))
243
+ if (! m_AlchemyLanguage .GetText (OnGetText , OnFail , < url - or - htmlpage > ))
235
244
Log .Debug (" ExampleAlchemyLanguage.GetText()" , " Failed to get text by text" );
236
245
}
237
246
238
- private void OnGetText (TextData textData , string data )
247
+ private void OnGetText (TextData textData , Dictionary < string , object > customData )
239
248
{
240
- Log .Debug (" ExampleAlchemyLanguage.OnGetText()" , " Alchemy Language - Get Text HTML response: {0}" , data );
249
+ Log .Debug (" ExampleAlchemyLanguage.OnGetText()" , " Alchemy Language - Get Text HTML response: {0}" , customData [ " json " ]. ToString () );
241
250
}
242
251
```
243
252
@@ -246,13 +255,13 @@ You can exctract the Raw Text from a URL or HTML source.
246
255
``` cs
247
256
private void GetRawText ()
248
257
{
249
- if (! m_AlchemyLanguage .GetRawText (OnGetText , < url - or - htmlpage > ))
258
+ if (! m_AlchemyLanguage .GetRawText (OnGetText , OnFail , < url - or - htmlpage > ))
250
259
Log .Debug (" ExampleAlchemyLanguage.GetRawText()" , " Failed to get raw text by text" );
251
260
}
252
261
253
- private void OnGetRawText (TextData textData , string data )
262
+ private void OnGetRawText (TextData textData , Dictionary < string , object > customData )
254
263
{
255
- Log .Debug (" ExampleAlchemyLanguage.OnGetRawText()" , " Alchemy Language - Get raw text HTML response: {0}" , data );
264
+ Log .Debug (" ExampleAlchemyLanguage.OnGetRawText()" , " Alchemy Language - Get raw text HTML response: {0}" , customData [ " json " ]. ToString () );
256
265
}
257
266
```
258
267
@@ -261,13 +270,13 @@ You can extract the Title form a URL or HTML source.
261
270
``` cs
262
271
private void GetTitle ()
263
272
{
264
- if (! m_AlchemyLanguage .GetTitle (OnGetTitle , < url - or - htmlpage > ))
273
+ if (! m_AlchemyLanguage .GetTitle (OnGetTitle , OnFail , < url - or - htmlpage > ))
265
274
Log .Debug (" ExampleAlchemyLanguage.GetTitle()" , " Failed to get title by text POST" );
266
275
}
267
276
268
- private void OnGetTitle (Title titleData , string data )
277
+ private void OnGetTitle (Title titleData , Dictionary < string , object > customData )
269
278
{
270
- Log .Debug (" ExampleAlchemyLanguage.OnGetTitle()" , " Alchemy Language - Get Title Url response: {0}" , data );
279
+ Log .Debug (" ExampleAlchemyLanguage.OnGetTitle()" , " Alchemy Language - Get Title Url response: {0}" , customData [ " json " ]. ToString () );
271
280
}
272
281
```
273
282
@@ -276,13 +285,13 @@ You can combine multiple requests into one call using a Combined Data call from
276
285
``` cs
277
286
private void CombinedCall ()
278
287
{
279
- if (! m_AlchemyLanguage .GetCombinedData (OnGetCombinedData , < text - or - url - or - htmlpage > , < includeSourceText > , < extractAuthors > , < extractConcepts > , < extractDates > , < extractDocEmotion > , < extractEntities > , < extractFeeds > , < extractKeywords > , < extractPubDate > , < extractRelations > , < extractDocSentiment > , < extractTaxonomy > , < extractTitle > , < extractPageImage > , < extractImageKeywords > ))
288
+ if (! m_AlchemyLanguage .GetCombinedData (OnGetCombinedData , OnFail , < text - or - url - or - htmlpage > , < includeSourceText > , < extractAuthors > , < extractConcepts > , < extractDates > , < extractDocEmotion > , < extractEntities > , < extractFeeds > , < extractKeywords > , < extractPubDate > , < extractRelations > , < extractDocSentiment > , < extractTaxonomy > , < extractTitle > , < extractPageImage > , < extractImageKeywords > ))
280
289
Log .Debug (" ExampleAlchemyLanguage.CombinedCall()" , " Failed to get combined data by text POST" );
281
290
}
282
291
283
- private void OnGetCombinedData (CombinedCallData combinedData , string data )
292
+ private void OnGetCombinedData (CombinedCallData combinedData , Dictionary < string , object > customData )
284
293
{
285
- Log .Debug (" ExampleAlchemyLanguage.OnGetCombinedData()" , " Alchemy Language - Get Combined Data Text response: {0}" , data );
294
+ Log .Debug (" ExampleAlchemyLanguage.OnGetCombinedData()" , " Alchemy Language - Get Combined Data Text response: {0}" , customData [ " json " ]. ToString () );
286
295
}
287
296
```
288
297
0 commit comments