|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑 * ^4 k# V2 e5 S, f
zhangandma 发表于 2013-1-25 10:16 5 P+ h9 U& v9 G- W9 V
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
) w& o; \7 g6 J1 z4 Z. H因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。2 [( K+ C' _5 x( l( |
1 ~! S0 E' u8 R+ }) J4 `$ h+ I
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)
6 g7 l9 C/ {" C2 Q0 }( s6 V) r' @ - {6 Z" f- q- ?+ m8 A2 E9 e
- string selectedText;
# p. f; z- ~# z: P - IEnumerator enumerator;9 |7 C9 F _4 _
- string str = "";
4 J9 e% v; r9 I! X' h2 b$ L& U - ArrayList list = (ArrayList) g_protected[g_projectedCategory];4 n6 l& A/ u$ ?% n: H
- try
( [& y3 l! A/ |( a& n9 I$ V5 b, L - {. m7 @, y+ N) u5 J
- enumerator = list.GetEnumerator();
; k# f& z3 j8 \- @ - while (enumerator.MoveNext())& _4 G" r3 y) O0 J' C; ]3 d
- {0 U# E& L6 d: e4 c& ]) ]: Z
- string str4 = Conversions.ToString(enumerator.Current);
) T. u# S: G: v7 }: t4 ` - str = str + str4.Trim().ToLower() + ",";/ K5 x: M7 C* e! L( v
- }
O4 D' @( ?# f; B4 Z( c: K1 c - }0 O, A* B4 l$ E0 R. Y
- finally
6 ]( ~% I4 R# ~7 \. `7 E - { X/ ?$ u( l9 \+ @9 z6 r
- if (enumerator is IDisposable)/ n, t5 h- x$ B5 T5 U
- {
3 [7 l, D) Z5 Y% r - (enumerator as IDisposable).Dispose();
5 f* a, b, F5 P3 O3 h1 O+ E - }
( E9 `! o& q \! o0 N' v7 c, L8 S! b& B - } _ k1 [' H j; ^- v/ J
- if (str.Length > 0)
- z7 K r) H& u) M/ Q, @ - {& s4 L4 b# D: a8 T0 _, n
- str = str.Substring(0, str.Length - 1);5 y0 Y S% R' o! ?
- } C3 w6 f5 k: l, ~- [" ^! V
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
9 r2 [1 Y/ l; i5 T" c# I - {
1 z4 `, ?1 T2 ~& e) _) F/ X g4 d - selectedText = osd.spinTab.spinDoc.artf.SelectedText;2 S( ^" E w7 v9 F& L
- }
' p) y* e# X: Z0 J6 I; Y. a7 h/ V - else; n# m0 h; B" b0 V8 c& ^* m- w( Y! z
- {. X, d* h& N/ Q t+ L: e8 b9 [6 G, u
- selectedText = osd.spinTab.spinDoc.artf.Text;. A( v' n: Y f7 X4 |- e
- }9 ?) b. H( y+ t9 S7 `
- 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, ""));& o7 k% y" L) \4 S4 S
- if (txt.IndexOf("<success>true</success>") > -1)
. v$ I0 }2 S' r, t! l - {
( ]! m* r, ?$ m. _ - txt = txt.Substring(txt.IndexOf("<output>") + 8);) }3 n! v6 N4 V* P( e; y
- txt = txt.Substring(0, txt.IndexOf("</output>"));5 o e. z s6 B2 d
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
8 ^: p* d7 s1 w# ` - {+ H' i0 Y5 J$ X* _1 O c
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
7 H. }: j/ {% ?- ~ - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
4 L! U+ t& t8 u7 O4 ~9 p - }
1 K% H+ ]9 l( c6 b( i$ b - else
$ u) R7 E( J. S/ h: D - {
. Y* r7 p/ g C6 k* b1 Q* [0 M - osd.spinTab.spinDoc.artf.Text = "";0 Q' s4 W0 B$ x, m
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);- O. O/ a6 ^9 `% f& X
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
# Y8 J# x* H: c2 Z - }
1 L' d% `/ r$ U% |( R$ ^) M$ u - }" y K' O: o6 u. t' M' f
- else if (txt.IndexOf("<error>") > -1)- O- O6 ^- Q- c/ k. k' v
- {3 A( b8 ^7 ^7 F: Q
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
/ ]9 V2 r: O7 P9 k ~7 u) F - txt = txt.Substring(0, txt.IndexOf("</error>"));
" o: l! S( q6 w% e* R - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);9 r D. T7 Y% I1 w) c$ M9 Z
- }! U) M3 h% {% r/ d# {
- else
5 Z' m: d7 v; { - {' c9 y! I- ]) 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);4 H$ }2 J* a _
- 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, ""));
$ P7 a' E. c3 o3 o) m: ^4 O: l - }- M) r# w, I. r- C( h
- }' a- j2 l5 ~% j n
1 L! G) `& w; W-
" S' X. ?/ F& R5 o' P - % d) d3 h2 `5 d9 j% N
- Z9 X' `$ F& \: f) l2 q) X% i' K4 Q
# y5 t2 l, J" V- 3 ^9 ?- X& ]# T# n0 Q$ C6 q" B
复制代码 |
|