|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
$ g" o6 ^: P$ P3 [. e1 j3 |" kzhangandma 发表于 2013-1-25 10:16 
6 R; z" V# y9 I8 u) u0 ~发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
& k% a; ?2 }# u ]8 P% X- [因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。% S/ G, a3 U9 T/ d
2 G$ C; Q* t' E1 Q$ ?0 t7 y/ t5 sstring 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# i% ?4 m$ s8 A- f - {
' E, C' N7 w. M( N3 r - string selectedText;
) }! b) {$ g( Q; v - IEnumerator enumerator;
) m J a* E' Z& C2 M+ Q - string str = "";2 \& Y3 K% m7 L* r
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];/ D3 @( b6 B0 W7 Y" p/ e
- try
) m! p" p0 @ ]. A. f- p. q K - {
% U7 r, {& ]9 q* u2 C) w0 ^/ E - enumerator = list.GetEnumerator();
. [( a% M3 A, Q - while (enumerator.MoveNext()), P. e/ H5 }; L+ P. P% W
- {
# A5 i# _ X% P& E/ P; u - string str4 = Conversions.ToString(enumerator.Current);( ^$ N5 x- j" u' m
- str = str + str4.Trim().ToLower() + ","; o4 f+ r& e9 j
- }# a6 |7 u* y: J" P4 u4 W4 Y
- }2 K; a4 V& s9 C$ h. z8 P
- finally
7 k% z/ j$ ]" }" h3 H - {
/ L2 @7 ~) W9 i5 o6 L" | - if (enumerator is IDisposable)
) l4 W6 n. [' G6 a! H: u- I - {1 E0 W" u+ M7 r" G. R" o6 G
- (enumerator as IDisposable).Dispose();" Y5 ` d& e! l" A/ x$ `9 x) n
- }" S k/ o5 \- P9 P# o4 G
- }
3 t( l" k6 Z B8 F- s - if (str.Length > 0)4 u* ]* I' `. ?! W' _
- { v" Q$ e' U7 Q X
- str = str.Substring(0, str.Length - 1);
/ O% W% X( t$ @* ]0 L1 h. e - }
0 f: o* i2 h0 ^ - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)& Q* S" C2 F0 K6 p/ d% B
- {7 A6 {8 D- O( H( G; M
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;. Z) X- c3 e9 u
- }8 c! X- w( R/ L. y0 T5 [
- else
/ w, t# c/ j& O( n8 l$ x& ^; w - {+ U* r3 B Q# q* n9 O0 H+ t
- selectedText = osd.spinTab.spinDoc.artf.Text;- o& h4 h9 r% U5 D6 l
- }$ W% G# _ X! O& Y J5 g9 p" D2 M7 X
- 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, ""));0 X; a" T! U* ?5 ~9 i
- if (txt.IndexOf("<success>true</success>") > -1), e* p' m) u" |4 v5 L
- {* R( [& L" y2 `
- txt = txt.Substring(txt.IndexOf("<output>") + 8);
2 L9 w9 R! v7 B- p! h+ F- \7 r - txt = txt.Substring(0, txt.IndexOf("</output>"));) {5 [% K& q8 ~/ c8 r1 c
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
7 Z9 T9 D0 M2 d+ ^9 ]3 x: } - {- {: _8 y7 w; V0 }" ?
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);' L8 m& d6 B" t' g9 t
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";+ Z/ c) K' R% z. l
- }
% T% O7 D) k# o; d+ I! M4 x - else V" |% I% k8 j8 N
- {( \: }. g6 A! k9 x6 e
- osd.spinTab.spinDoc.artf.Text = "";
/ h- r h' c- d6 g! t3 y v - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);/ F R. f7 G* U% |7 b0 q9 N8 W
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";1 @2 K# X1 c; l5 d( w4 b
- }# u% [# W" ?0 c( O& Y' b; N
- }
9 T- ?/ a: e, B - else if (txt.IndexOf("<error>") > -1)
- r8 ?# H) w& } - {
3 @; Q. Y- c. T* [* G0 x: P - txt = txt.Substring(txt.IndexOf("<error>") + 7);* w! M! T5 o) E: e5 _* Q
- txt = txt.Substring(0, txt.IndexOf("</error>"));
/ A# x' g( s2 s' i - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
7 O3 [ x" w: F4 w! } V - }
$ A% Z" M) O T \3 Z4 q) R - else# ]% `7 x% h' Y8 @$ V: Z! j1 D
- {
2 b4 @" ]7 ^1 v8 n: U - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
$ @9 e3 k4 k, U9 A, 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, ""));
% R4 @2 R: e6 X# _1 F - }( d; A- v$ S9 v! ]* z0 i! w" A$ K
- }; u2 J F1 M* S' j6 `$ H
- * ]$ Z0 {6 T% h' [8 G% h$ J
-
: S0 S$ s F+ I7 ]; ]# j6 Z - - o$ H7 E; n: t9 Q" n! n
-
! X/ s8 ^( {/ I! T
4 O/ `. z( [1 e7 r7 i" o- ; V1 W1 ~7 V9 g, K. ^$ y6 p4 z
复制代码 |
|