|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑 . X6 C. o; [9 {% \ ]! A- {- `
zhangandma 发表于 2013-1-25 10:16 0 f2 t6 q3 U' Y& b6 i& ^9 Y: @) k* U
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 / Z5 @+ ^/ r6 ~* J6 x D2 Q
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
- f3 y4 @6 m: O) p& Z/ `9 ^/ \# t/ g9 L$ \. g/ {% Y) X0 a
string txt = Conversions.ToString(EasyHttp.Send("http://thebestspinner.com/api.php", "action=rewriteText&inapp=1&session=" + g_uniq + "&protectedterms=" + HttpUtility.UrlEncode(str) + "&text=" + HttpUtility.UrlEncode(selectedText), EasyHttp.HTTPMethod.HTTP_POST, ""));- internal static void AutoRewrite(ref OpenSpinDocument osd)
- p- }, V& K' } - {- [% h3 n3 W& _/ M) H2 D
- string selectedText;
/ |' L ~) v$ k( J( g# c5 @ - IEnumerator enumerator;
4 n6 B0 I* b8 B, O) M - string str = "";' o" q1 R, C; m6 \/ F# Y; b$ r
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];
* t7 e$ c" C8 `2 z. W+ z - try; ^5 x2 J8 F# o I! e& l% t0 C) D
- {
9 i+ d' j9 B1 l* `2 S* t; x& D/ s( N - enumerator = list.GetEnumerator(); Q/ v1 H, C2 M
- while (enumerator.MoveNext())" p. U, V o3 T1 ~. H3 B
- {
* X* l8 t" @5 e* b: X2 F4 l - string str4 = Conversions.ToString(enumerator.Current);0 W) C6 z; `" W# Q( ?8 }; X
- str = str + str4.Trim().ToLower() + ",";. G! K. t# H8 I0 j* g
- }
$ C$ v. ?& I9 Z, t - }: M: a+ t8 U: r" D7 m% I" H% r
- finally
: q: m, R" w1 x" j - {: l) |3 k- a" {+ p l- ]* c, b
- if (enumerator is IDisposable)6 W3 I3 @% i1 c. L3 C
- {2 k5 w6 Q' m* b- I, g* P1 I6 E
- (enumerator as IDisposable).Dispose(); Y! k# O( B* X, w
- }2 E/ j1 |: I; c7 b: \* i
- }
3 j+ M W+ g6 m, Z# g - if (str.Length > 0): ?5 i8 q5 N; `" i% B0 S
- {5 Y! Q ^; U/ n" X5 }
- str = str.Substring(0, str.Length - 1);
1 V/ \5 @* X. j9 i - }% m8 r! f) i7 z$ r& v$ a
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0) G% s1 \" H9 `% r; I
- {% K0 g1 ]4 i3 V ? V1 t8 ?
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;8 Q: s8 X7 ^% W2 B2 n S
- }
( V* A1 w! P: U3 V5 x3 t - else& l0 H: ~5 N. [* ^6 o
- {
6 Q9 I$ j/ \7 Q3 D5 v6 Q - selectedText = osd.spinTab.spinDoc.artf.Text;
2 M& r. Q w' E+ w, x. c6 d3 r - }
3 L6 ?: v7 ?( C2 V( C. N; z - string txt = Conversions.ToString(EasyHttp.Send("http://thebestspinner.com/api.php", "action=rewriteText&inapp=1&session=" + g_uniq + "&protectedterms=" + HttpUtility.UrlEncode(str) + "&text=" + HttpUtility.UrlEncode(selectedText), EasyHttp.HTTPMethod.HTTP_POST, ""));1 c/ k: L2 Z! S8 J! R0 @7 n* H5 C8 m
- if (txt.IndexOf("<success>true</success>") > -1)# l! ^. | `- C8 Z2 s2 K* X! R' j' {
- {
1 z/ K4 F: x1 @/ s( h2 c3 M+ m - txt = txt.Substring(txt.IndexOf("<output>") + 8);
2 b3 N- j! e/ N$ x: F- r- J7 j - txt = txt.Substring(0, txt.IndexOf("</output>")); E6 j, j9 P; a/ G! c3 |; i# D
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)/ n1 h" F* z# X1 F% Q4 {* u" \7 N
- {( f* U$ E" i/ z' N+ X' C! C
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
. h& I+ C; f" }2 G0 g0 S* y - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
, [! q9 B( D+ @! y q0 M - }: S0 T7 d2 W) U0 Y
- else
$ w0 u7 @: O- w8 q+ J, v! L2 ?/ H - {
* n* k# Z- O S' Q - osd.spinTab.spinDoc.artf.Text = "";: Z {" y/ e$ j% L5 V$ c
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
/ |) P2 r. [+ Y9 F B+ F2 G - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";5 F0 G+ o& l7 d3 v# z( E% {* C
- }
" D1 A% [2 p$ S! J% g3 n - }3 i4 [4 ~- _: d4 B) a
- else if (txt.IndexOf("<error>") > -1)
: V8 v+ `, v/ P5 C. M - {
5 ?; [ }, v( @2 J' R" Y$ n - txt = txt.Substring(txt.IndexOf("<error>") + 7);
9 f; r' y; m; ~9 K% @- E - txt = txt.Substring(0, txt.IndexOf("</error>"));
+ y: p7 |5 y' w; ]4 X! w - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
. ~3 M6 y0 _5 B( x9 v - }
. O6 @( I: q- r% {! S% ` - else
( Y1 m& \& M/ Q: L8 G! G; C - {) w- U* i" n, H9 t
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);3 Y3 n7 |: D' K6 E; k6 s+ P( B
- txt = Conversions.ToString(EasyHttp.Send("http://thebestspinner.com/", "action=app_rewrite_error&uniq=" + g_uniq + "&protectedterms=" + HttpUtility.UrlEncode(str) + "&text=" + HttpUtility.UrlEncode(selectedText), EasyHttp.HTTPMethod.HTTP_POST, ""));3 i. a! b# B7 A
- }
, S. h4 [* C0 ^3 D8 _5 @ - }7 E; [$ P. {- u% Q4 P" x! T5 g4 n4 q
# g3 ^: x# z/ N2 O5 `. D- D- 5 Y' ^, W# ^1 M: |* N
- & F# d* y" W" k% ^ \
-
% O z6 u! e5 M - 7 w0 e9 v7 R" k7 a0 z
s4 l/ B+ P2 L; V! E# a8 u
复制代码 |
|