|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑 8 H+ ~8 z: r7 }! }" `1 n+ N
zhangandma 发表于 2013-1-25 10:16 ' M }8 B" h# r) @8 i9 |! u- V
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
0 w% J: B, z8 W9 R0 v因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。: c% b1 S# t# g$ z% `7 Q
1 \% o4 N& O# y! r9 `4 J6 Y) 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)+ v/ E" V: G* n1 Z
- {
8 M8 a$ g/ L/ ^3 f* u# f) v5 a( } - string selectedText;: y6 I" ?- y' a7 E/ g9 `
- IEnumerator enumerator;) O' g8 ]! p- c7 \
- string str = "";0 c" r- `! j7 V$ N
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];9 q/ Y( o+ ^) C5 y' L
- try
0 |# O: m* f c' t5 e) g- i; R - {
f7 N o1 r9 v$ S% f5 O9 B - enumerator = list.GetEnumerator();
# o; X+ o6 }$ A0 B- Y8 z& ^' `* ] - while (enumerator.MoveNext())
# s: D5 }. W& ?8 |5 R2 d - {& c, b( U: h1 `
- string str4 = Conversions.ToString(enumerator.Current);2 V3 ^% b9 b. F! t. A
- str = str + str4.Trim().ToLower() + ",";6 L5 A1 w; D$ T0 t+ d" T
- }6 }1 `( f' i, Y. j$ i! y" x
- }
& o/ s- a4 e8 i" L/ h0 U' x - finally, B2 X |4 l1 \
- {
; M: Q0 k) t4 x - if (enumerator is IDisposable)
6 f+ y+ I& v- H. r5 ~ - {: V( f& I7 O' {+ X ?) x8 P" w3 u
- (enumerator as IDisposable).Dispose();( r' m4 Z" {; y# C- W
- }
' f; l6 z6 U. z6 Q8 t7 Q - }
+ m- q9 r- b" a8 Q5 u3 S( ]. L - if (str.Length > 0)# f2 U5 R; n+ M* s. s- P7 f @
- {' I" K. q( s5 ~4 u+ F
- str = str.Substring(0, str.Length - 1);
, @2 t' c: ^5 J - }5 ]$ \/ O! a* [ \
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
2 N4 f! x& V$ B e. | - {
+ ?; Y& x( D$ \7 y$ Z G - selectedText = osd.spinTab.spinDoc.artf.SelectedText;8 F( N/ R! L) J
- }2 p1 ], `) M6 h- ^
- else2 V5 X( \1 N: n
- {
% S+ Q% F* R7 d4 K. K8 A& h - selectedText = osd.spinTab.spinDoc.artf.Text;& ~) u8 B* d8 j; r) K2 R
- }
8 v% R4 ?7 v# o9 I/ s" N; Y3 f - 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, ""));2 p* ^- ?# H# g. m: g' H
- if (txt.IndexOf("<success>true</success>") > -1)
% A& b$ J% ]4 V7 a1 ~ - {
7 A/ g. G$ o! e1 J$ k; {+ B - txt = txt.Substring(txt.IndexOf("<output>") + 8);
& R/ \7 T& [/ O/ m- ] - txt = txt.Substring(0, txt.IndexOf("</output>"));+ t5 C4 [. D7 Y" O
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
( h+ G# Q! Y! p- @) O G: u' v - {
2 a% m! D6 Z! Y1 V0 B0 Z) N - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);7 d, m T! w. ^* z5 L9 b# I
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";1 F, F$ F9 c1 V
- }
! K$ W, q8 F4 j4 f0 [, e3 n - else0 \6 R9 F5 i5 [! U X) p6 w
- {
; q" _- i; Q, }* T& `% L6 ] - osd.spinTab.spinDoc.artf.Text = "";$ L- }; h ?3 H+ L
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);+ Q+ P% ?$ f& A& ]5 p4 @
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";; D" n* E. |- e/ A, c: J& Z
- }
0 t% n7 Z# K* K* U$ R - }
: | Z r" c/ T9 N - else if (txt.IndexOf("<error>") > -1)7 t# n. ]! n. d& a9 y
- {
" y; t& j. Z d$ e# D: r" ` - txt = txt.Substring(txt.IndexOf("<error>") + 7);. J% F2 o/ u$ W1 \' W
- txt = txt.Substring(0, txt.IndexOf("</error>"));+ b- r- V4 G4 m0 y u& O8 v
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);8 _% u' g" C {# o R- ?8 E
- }, @( L1 M" | D& x
- else
$ c/ [! k7 A( h6 F2 D7 [. J - {% e) z- d& a7 ~" P8 ^9 A
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
8 y/ Z% p2 G1 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, ""));
7 }* H/ Y0 m" ?' n# z- G - }
$ d# d4 h- t5 K$ a( U5 v - }" z: n5 i+ z6 f
% x9 M* a+ `# G0 X3 ~( E# K-
2 f6 i% G1 s3 H; _ - * y, @: ?$ L, q+ [3 ^0 g! W5 I
-
) {" d. v4 H9 A! W0 g
" i" P; H' t! w( L3 X$ A& l- : b0 O9 Q5 M$ d
复制代码 |
|