|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
$ j# h! V8 Y: [3 F: J! l' }zhangandma 发表于 2013-1-25 10:16 
6 l6 N+ B5 }' J4 H) }, x2 v. X7 [7 }发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 u" z$ A) t2 ^4 ]8 v; F5 C
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。2 @5 k/ b2 V, B6 R- C) ?$ H
- p' _3 t6 ]1 \; U' e5 ^1 n
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)
& M A* C4 Z5 ~4 f - {. i X( H7 s1 P- G. j" b Y4 o, c F4 n
- string selectedText;2 p5 X) X, R1 G5 _& Q6 h5 A
- IEnumerator enumerator;
1 T5 x! `) {0 h - string str = "";( V, L) o+ K ^2 Y% z" d1 Q9 E
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];# v6 T$ {# _: {$ @9 Z
- try, ~( B* F. Q: q+ U( n! y O
- {
+ D7 @+ _7 x: f* ~5 X - enumerator = list.GetEnumerator();
$ o v, n* B- Y. Q/ d* `4 y - while (enumerator.MoveNext())
* X! E2 P% n& q - {
O. Y" |6 Q9 ^2 @( Z0 L - string str4 = Conversions.ToString(enumerator.Current);
6 n: P4 y( A% [# m0 E - str = str + str4.Trim().ToLower() + ",";: t! R$ y# Z8 r( j$ ~( e; w
- }* f- b9 L. a+ v' v" n1 z }
- }2 G6 @6 v! s( s0 c- c
- finally
( d( Z8 ~# @( y% g* k - {, Y6 D8 S( d6 \) y! E9 N
- if (enumerator is IDisposable)9 i: o9 Q" U" X" l; C/ F* I
- {$ T. g! ~+ n8 E/ Z' [% l
- (enumerator as IDisposable).Dispose();
5 E0 M3 O+ I& M2 W7 C' W - }1 e; I: M/ B. d+ G8 p* m8 _" O
- }
$ s5 I9 K+ J# J - if (str.Length > 0)+ b. J0 k* k+ K
- {8 e. T D$ Z5 G9 `$ Q
- str = str.Substring(0, str.Length - 1);
$ j i( H$ j# i# S - }
* W5 z9 k1 ^( X! Q! r$ W - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
; x4 r$ ]& I% g) f8 H" O6 b - {
4 [( {( E+ a6 ^5 |, d - selectedText = osd.spinTab.spinDoc.artf.SelectedText;* |4 |; V. N8 }
- }
- Z0 B9 J! x% b7 j - else
5 H. X6 y3 ~9 t+ L - {" W/ T8 N: p Y4 F6 e
- selectedText = osd.spinTab.spinDoc.artf.Text;) o$ [! G/ K$ Q) k1 n/ E U2 u0 a
- }
& P) j3 ~( G, C# ~' ?) b - 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, ""));
3 ]( Z) [5 \+ d. q+ F9 Y - if (txt.IndexOf("<success>true</success>") > -1)
& h- F5 I) P1 Y8 y$ k0 k6 H. G9 Q - {) x1 V% g2 s; Y* i( @& a
- txt = txt.Substring(txt.IndexOf("<output>") + 8);9 ~5 E$ d" S1 V4 S1 p" _2 f. x% o( C
- txt = txt.Substring(0, txt.IndexOf("</output>"));
5 M8 S7 X1 }# l* l' a2 r - if (osd.spinTab.spinDoc.artf.SelectionLength > 0): v9 }1 R- M t* g4 L
- {
" r4 e- \) I# h& J& w! Z - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
( O3 d+ _9 G+ V/ j5 P8 Y* H! u- g! _ - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";# [ H0 ^/ @7 A( c0 i# |- Y+ ~8 _
- }
" [7 q2 N: X% d% U% T1 j0 Q2 K) n - else
7 ^8 @( c! \/ O0 k- @" \( F - {
* a! E0 c) W; i9 W8 |* l$ P6 x - osd.spinTab.spinDoc.artf.Text = "";
( d7 e9 s8 o+ z' |7 e- q0 ^5 j/ }: T - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
% D3 G0 p- d- F+ Z; Y( g# P. ` - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
* ^/ K, K% Y) I - }
1 W: `; f1 m8 C% J* q- Q# t f - }
; \9 Y; q y/ [9 Z- w0 }" L0 N9 t - else if (txt.IndexOf("<error>") > -1)+ |6 P7 W( c: T9 B, w% v+ c
- {0 r% f! G2 s& J. i) Z6 B' H6 r
- txt = txt.Substring(txt.IndexOf("<error>") + 7);' D2 t, Q& [' D7 g# ]" [4 j K0 L
- txt = txt.Substring(0, txt.IndexOf("</error>"));
( E; M1 n$ ]5 ]. [3 E - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);% U* N: _; g$ N% L E z+ z, ]
- }8 \8 f$ r" G# q( W+ F
- else+ ~8 G* i* s0 T+ d
- {. u: z* W) \# j2 e, W* R
- 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 c! U& A! J- a$ f
- 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, ""));
. l) r. _, L/ ]% ] - }, @$ f7 r9 u% u% L& H$ N% w
- }
5 u3 J1 Q4 v8 t) o! X8 s
. m- _6 c! A. w m4 O3 ~* f D-
9 X+ L$ U) r& U0 C - + D1 `$ b2 H) P, m0 W, P" `/ f
- ; g' ^; I) w1 k* u- V
% \( V, V& K8 e, m0 N% N- 3 h M7 b) N g9 u |. `8 {
复制代码 |
|