|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
% {% O, j$ i- f* x+ }& t; mzhangandma 发表于 2013-1-25 10:16 
( \' M+ u, K6 b% U4 o发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 9 Q) ~5 s1 e1 w. \0 M. I, r/ s# I
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。; g' Q2 P( \+ V5 C1 F2 e
" C( m# W7 t+ z4 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)) ^8 r2 l) [3 s# X1 b
- {
% Q: r" e0 u- h& @ - string selectedText;: { e; ^) Q* L/ G
- IEnumerator enumerator;
0 z% ^! h+ [6 V) M3 }; Q- @' { - string str = "";3 N6 ?5 i: S! Y3 r! W+ s
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];
1 F" f8 k2 N3 |4 ]0 f - try* t" R# `# i8 \; R
- {8 o) ], S- }' i, g/ m7 l
- enumerator = list.GetEnumerator();0 P# s( L4 D2 L/ x
- while (enumerator.MoveNext())
7 o+ }; j$ _ ~9 ^$ u4 w* k - {
* O' j+ J5 V2 @- ^( W - string str4 = Conversions.ToString(enumerator.Current);- x% R" r. @4 M: x0 T% G; M
- str = str + str4.Trim().ToLower() + ",";& M& E1 _/ I/ x
- }6 G4 H: k0 p( X# R) \. R
- }3 C+ ]5 Q4 w+ M
- finally$ R4 x8 Y4 `9 J% x; N8 X- [
- {, L9 \7 _4 Z9 Y; G8 Z; r8 G
- if (enumerator is IDisposable)
/ f9 @/ \2 y( ^6 ` - {( L! W0 a' Z3 j0 M2 o# x2 Y* c
- (enumerator as IDisposable).Dispose();
& C. z5 T' r9 E - }
" `) O8 r O1 m - }
; j! S1 n' |: U/ K - if (str.Length > 0)
8 I7 J5 e# l$ Z: G: m/ d - {4 v9 K+ d0 K% D, ]. X8 w4 Y
- str = str.Substring(0, str.Length - 1);4 G: p1 \9 @: U
- }
7 L& W* h( P6 ~+ ~) i h' d - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
9 y o4 G; A" ^2 n - {0 X0 D1 V( e" k8 w# F+ O% K
- selectedText = osd.spinTab.spinDoc.artf.SelectedText; o( y! R* A8 O! D
- }0 F+ j6 d/ c3 o6 M
- else
' e6 ^- E% i. B( g: c- g& F - {" M& }$ k8 h2 E! @- o
- selectedText = osd.spinTab.spinDoc.artf.Text;3 C3 }2 O- Q% O$ N% s+ o- T4 v
- }
7 K E2 l. d6 q0 l9 g- G. d - 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, ""));# L9 d' ^5 j& `4 e6 S0 u$ V8 {# ?
- if (txt.IndexOf("<success>true</success>") > -1)
' ^4 d- @# N$ d/ _ - {* J5 F7 a' K( g, Q) N) E0 g
- txt = txt.Substring(txt.IndexOf("<output>") + 8);
1 w0 r7 w4 Y& `1 Q `5 f - txt = txt.Substring(0, txt.IndexOf("</output>"));, j. Z3 n7 c) A3 d, g* O: m* o
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)5 W! o2 h$ b2 @5 ~- V
- {
8 H5 R- u+ H; E# S, [ - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);, A8 S% [; Y* X- T3 n- l
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";1 X" H9 a3 E$ L9 b) e) z( G
- } M- t5 l/ E! \1 I4 a
- else& D& c* p& G& z
- {
" @ P0 `6 S: j - osd.spinTab.spinDoc.artf.Text = ""; B y M, I8 L9 ]/ y3 e, ~
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
4 t* D/ Z, Q" D, M - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
& s* `8 d) N5 c - }
8 A$ q w1 E$ C' J0 s! H - }
: P5 z8 Y8 z8 K x: j$ r& R - else if (txt.IndexOf("<error>") > -1)
$ s3 ~5 i( {1 L. r' @. `& s - {
$ @* ]. l% {9 Q$ [) T% m5 [) }' [ - txt = txt.Substring(txt.IndexOf("<error>") + 7);( l* m) }' Z5 ~% o: w( k4 K" c" Z
- txt = txt.Substring(0, txt.IndexOf("</error>"));" T& D9 M; n! w" u* K- u
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);3 c+ ^1 |- _2 b- x# K R1 n, n
- }4 D" ?" i7 G* U2 \+ Y
- else: t; {& s9 d% h @: s1 N" y
- {* p& t- I* Y, ^, X9 E# l
- 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 w6 C' P, c$ _; |( [3 ~' O: r7 t, w/ |
- 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 i3 l |5 r) W; P) W* D - }
" A3 C" B. H5 N. \. l/ I, Q - }( i! ^4 d7 X. v) F. z7 E
- ) n Z; ]$ x$ `/ M* \! E
- / h7 o; R+ y) J1 h# Y' c' o' V1 Y
% d4 L- V& j; [5 k* k- , A% H) x% F( I
$ U. o3 O7 z+ y- b
2 X- k5 A( l7 g6 f' k* q9 X
复制代码 |
|