|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
# Y* p* Z: g+ s, r! M. N# L8 Pzhangandma 发表于 2013-1-25 10:16 ; {1 g* Z6 }* q+ d9 j0 m" F$ w+ j
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
- D# o4 e0 i+ B2 G l因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
( ~1 l. I0 a7 Z2 N
% A# W) `6 W8 Fstring 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 |8 q M4 V$ t$ F
- {
; p2 e7 s4 ?" p2 o - string selectedText;2 K% x* T0 a( G4 [, W8 r/ H
- IEnumerator enumerator;
' m! N I$ \3 I - string str = "";
, Z7 A% X% V" j# h; O - ArrayList list = (ArrayList) g_protected[g_projectedCategory];; W; `& O. j' g# i
- try% W, m: C- d; M- x3 f
- {
" O# d9 r2 W r - enumerator = list.GetEnumerator();9 c) m0 b' j# a/ h- N. `, T) V
- while (enumerator.MoveNext())% }1 n, z( Q4 m. i0 e! M
- {
1 r5 y0 d A/ T3 V( N" c - string str4 = Conversions.ToString(enumerator.Current);
( Z0 A8 X! T9 V) p i( a - str = str + str4.Trim().ToLower() + ",";8 Z9 F) m1 ]. D e5 P# j
- }
0 b, }. A+ f, M- J$ n - }; T, R2 u5 j4 m) \; d; J# g
- finally
9 ^" _0 O7 N. ] M" Y) c - {
; i7 [2 ]0 o* |2 w/ l' T9 i - if (enumerator is IDisposable)$ \2 C- l6 j% l0 Z& Q: A* g
- {
# p0 Z2 o, Z3 l0 [3 [ - (enumerator as IDisposable).Dispose();
# J0 F$ ?$ P6 Q8 T# I$ w: J - }
$ a7 p- M; _" r7 S/ H - }( e r6 K& I1 z3 [6 T( @$ Y
- if (str.Length > 0)0 v' {5 B, r4 W3 `6 J- b; ^
- {$ J3 L. n1 l2 n$ J" f4 O
- str = str.Substring(0, str.Length - 1);
1 l4 q) i/ B) S+ l) \4 Z - }; J0 n- o1 S4 O9 Q) M
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0): E# e" X8 ]$ K/ q4 r6 _" s
- { b9 z r3 K/ G* ^; E
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;
8 T# f. ?0 y( Z# J( k+ F+ ? - }1 i1 c0 r2 V3 @
- else
" s7 N& W) b4 _2 L' A8 j& S3 q9 g1 L5 X - {
, O4 [- y' }$ K" A& Q6 K/ k - selectedText = osd.spinTab.spinDoc.artf.Text;
. R" u( v6 B4 \+ [2 m/ W0 c - }
9 e: D3 q5 M3 } - 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, ""));
' [, p( q) H2 C# z# H1 \ - if (txt.IndexOf("<success>true</success>") > -1)
* ^4 ]5 {3 V1 } - {
- N9 ^7 ^) t/ j/ B( V. [. \ - txt = txt.Substring(txt.IndexOf("<output>") + 8);
" r# J8 _0 B) x" I/ }/ L - txt = txt.Substring(0, txt.IndexOf("</output>"));$ x+ Y6 ^( N/ ^/ a
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)( a6 ]+ ~% u$ B8 v T
- {5 W+ y/ U7 s+ Z
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);) D9 Q) p. O7 y7 J
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";+ Z) j- C. x6 R. s
- }! X l$ ` o0 V7 _2 v. G5 _
- else9 B L$ T: B/ L4 M( L
- {
7 k0 n b4 }; Q. Q& \# | - osd.spinTab.spinDoc.artf.Text = "";
' T h/ W( q" e; m: z6 m8 p - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);1 T" C! L( D5 h2 o. s* a* q
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
. H8 l& U5 w3 y- x, ` - }
, i8 B, W4 Z+ i3 w* T: z - }2 l' S/ {/ c8 `9 I% `
- else if (txt.IndexOf("<error>") > -1)
* V1 P- J0 |% n1 C/ _: H* N0 A, p' q - {
' a. _) S3 V$ R5 K. b9 a8 c* X& c - txt = txt.Substring(txt.IndexOf("<error>") + 7);
( C+ w# I5 t7 Z - txt = txt.Substring(0, txt.IndexOf("</error>"));0 Z. Q% ?5 Y) d. P. h# V! A! p: N. }
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);7 K4 a) x) q. w7 w9 k
- }% s1 R; h: C) N; K8 R' x2 f
- else
9 Z+ x6 g5 U3 ~7 R9 N - {
1 ~' b6 L: k: x: w; y7 s - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);2 n8 W) ~' f, d% `' N
- 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, ""));* O& S y3 d4 ~4 l. ~+ F G& [
- }
+ a2 o9 |* Z& m* a7 U$ J, ~ - }9 ^0 B$ G1 [) \3 w1 ?. e
- 5 j2 z8 u% n9 ]5 J
-
3 E: E/ Q A5 p+ E! D5 B
, P3 G( \5 B$ O+ ?- 6 @: q; V* O! P( J9 Z- d
/ S Q: V& B, ]8 t) g- $ F9 N: n( u3 S/ U8 }+ y6 D
复制代码 |
|