|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
9 {/ Q3 Z$ O) Qzhangandma 发表于 2013-1-25 10:16 " R! g/ q, @6 M, ^! Z5 |7 n
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 - g4 e8 A4 y% K2 d. G
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。 Z. I0 m- R( G2 K/ I: @3 a% V
: O, A) s3 W5 e& U/ ?
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), H. C' Q: H, S0 c, s' t
- {
& z8 f7 q5 h9 k7 Q; L. g Y - string selectedText;* l5 ?% }& p. Q6 X
- IEnumerator enumerator;6 x/ x) ], u% b3 ~- o" r
- string str = "";. {; P/ i$ N4 m2 D& Z( P
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];* ^" B5 j! o8 z: J( m$ q7 O. t! c
- try
# o2 [! |; {6 F$ o - {( h9 m/ z, |5 d+ k* d/ g
- enumerator = list.GetEnumerator();$ S% q- a( n6 @- }8 h
- while (enumerator.MoveNext())/ x0 G' G0 o# a6 ~5 q" R5 i" V
- {; E% M; z8 q& n$ }" j& z* m9 q8 B
- string str4 = Conversions.ToString(enumerator.Current);
5 M/ H( e1 R* Q - str = str + str4.Trim().ToLower() + ",";
2 L# b+ [* F0 M0 j - }; a; Q& |$ S8 F9 B8 F+ O8 R
- }* P$ J7 \2 m/ G- r- H, U
- finally4 S9 ^; Z0 X- n& U
- {. \0 K5 f+ Y q
- if (enumerator is IDisposable)
/ ?! K+ o$ G7 ^% ~% a% e8 d - {
9 T9 ?5 @1 _0 b% G5 G1 P) Z - (enumerator as IDisposable).Dispose();0 ^" f: Y3 E. s. g$ U9 p
- }6 W" K6 v2 J# C+ ?- c x d7 ^
- }: N5 Y3 D+ P) W" L5 R+ ]7 X/ O- g6 T
- if (str.Length > 0)
: y! c! Y5 u& h! {5 P - {4 t0 G. w q# P$ W8 }: P
- str = str.Substring(0, str.Length - 1);
1 I s0 i4 s( u. |1 P0 q/ `- F$ I; q - }
* q. M; P+ h# t( q - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)3 f& o, Y- @* k
- {
% ~: T; `6 B& a# N( F) h- B- W - selectedText = osd.spinTab.spinDoc.artf.SelectedText;
( I. P# Q) @! _: i7 v0 J/ R b - }. v* b' }3 `! l0 n4 L6 v7 ]" ?! c& j
- else
S8 X, { y* \. q- Q3 E - {0 Z! @& H7 s# C9 f3 `' U
- selectedText = osd.spinTab.spinDoc.artf.Text;9 j2 J! s1 c0 ^: K4 q% `* X4 m
- }- t) ?) f p) C; t$ M( j
- 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, ""));% i1 x: T# U5 P3 \2 }0 ]2 U; Q
- if (txt.IndexOf("<success>true</success>") > -1)
' c" X! h- D8 f# r - {
/ X5 x2 o% e5 p& [" W* O, e; h - txt = txt.Substring(txt.IndexOf("<output>") + 8);
5 ~0 Y7 P* e. L$ _9 Y F$ A - txt = txt.Substring(0, txt.IndexOf("</output>"));+ q8 x, j5 w6 M3 E9 |5 j
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
2 u6 F3 Y* Z( i) a - {
a7 w% c& P! g( }5 q" G$ ] - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
' ^* ]4 N& r3 r; {; n- H - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";& p) R! @! ?" ^1 R" ]( J3 L& J
- }
. ?- Y/ v! A) j7 Q1 u" R" B - else
# \' c2 e, G K6 v G: A - {# b( |0 s4 j# k1 x" c
- osd.spinTab.spinDoc.artf.Text = "";
3 |3 [, a$ ]- Y2 J9 q5 g& I4 [ - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
! h+ g9 S, U" Z% o - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";1 [2 T% f/ O0 D/ C Q& X/ Z- P3 @. n, M
- }
& ]. y* n) v% q; ? - }
! Z" j& |- Z) D9 r3 C6 E8 H - else if (txt.IndexOf("<error>") > -1), t; i1 t8 H& l2 q5 x% G: K0 G
- {- C, s. S* S* j% P" h% U- g5 Z$ T
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
% H# j% ?! [8 c. c! E+ C: y( ~ `& I - txt = txt.Substring(0, txt.IndexOf("</error>"));
/ U$ |( G8 G* { - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
; P n; s7 L; C8 {+ ~# q ^ - }- p/ H$ Y& c0 V( M m( G$ m
- else
6 a7 |7 x: \: h! E+ a7 c - {( m- h& I S* ~- h" }6 w
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);" X# y# o s6 t! V6 M6 j
- 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, ""));$ b% H, Y; I) U6 c# B( m/ D
- }4 ^" {1 O9 h/ m
- }
! W% \+ S' j# R, Q/ r7 b
& v( C e2 C5 ]' B- ; t* ]. _6 S$ T/ n
2 n C, m# w3 t; [- @-
, w% a' F9 a- w9 D - 0 k! w* y. Z% c$ G: U. Y8 K
- \" g! w5 g5 V9 z o, a5 O7 c
复制代码 |
|