|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑 9 a$ @1 f/ h# {
zhangandma 发表于 2013-1-25 10:16 
7 l Y4 b+ Z2 s; l- q发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
v0 }5 S$ W# P8 K% Q5 s/ {因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
! h2 I2 j* x+ Q) ?$ s2 G" M
% w5 a! |( Z/ R0 vstring 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)
, \ A* n/ B: Z' q; R3 d( l) i - {
8 u0 z w3 s3 s3 T% D/ l6 J - string selectedText; F9 u* h5 y' o3 ^
- IEnumerator enumerator;
3 X: @$ I* w7 x8 n1 i - string str = "";) P+ I- J; A$ @ o
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];
$ |8 x, y. n% a. s! R* O - try
7 o, v" A3 [ s6 d - {
0 }- a3 q2 \2 u0 {8 F6 }! u - enumerator = list.GetEnumerator();3 \, P/ L" y0 c& }# t
- while (enumerator.MoveNext())0 ~/ |6 [# V$ g, Y$ C' @7 @+ O# Y
- {
2 m" ]9 F" m( ?, C8 U - string str4 = Conversions.ToString(enumerator.Current);7 E; O- |; q4 x: [ _+ u" T2 U5 D
- str = str + str4.Trim().ToLower() + ",";; h! ~$ Y$ h5 i9 [. E2 D, g6 s
- }- o% G7 F. s- |" ?2 r
- }
$ @1 T' X9 e% q* m) @ - finally; I* t+ b8 k, k( [4 A( o! q
- {- h' j7 q2 z0 m% Z! E
- if (enumerator is IDisposable)
5 ^8 x! h1 g7 X - {
/ k% I. k( g: d5 C* P7 A - (enumerator as IDisposable).Dispose();$ c& x1 C( D* s$ s& h# n
- }' i/ K- F: q* j- O* S/ P
- }" o0 x8 \( m v* G; r9 E" @
- if (str.Length > 0)+ n% m8 Z2 p# D
- {1 L5 g5 @' r ~4 Q e
- str = str.Substring(0, str.Length - 1);0 R( v6 e0 C4 f" a
- }
# F& o! u X9 U; ?+ X - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
/ ]" G% Z2 c5 M - {
: M8 M4 e) ]: g: r5 ?! [" _; V% l" J - selectedText = osd.spinTab.spinDoc.artf.SelectedText;
% ?: b; G- s3 }' u3 E' i: A - }4 C. U4 e; {) Z3 j+ a
- else
( J, D+ g* T: h% Q$ p) [! Z* I - {+ f" L4 K" T, O+ i0 q+ S8 Q
- selectedText = osd.spinTab.spinDoc.artf.Text;
) V7 V/ p- ^4 w9 j; N - }2 b* e0 T7 {: |7 }# m) ^
- 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, ""));
3 i1 i$ t+ O/ x" [% G$ W8 M/ ] - if (txt.IndexOf("<success>true</success>") > -1)
4 u {- M- F" g& A: l" P - {5 o/ `4 V- I# k1 u8 b
- txt = txt.Substring(txt.IndexOf("<output>") + 8);
; t# a) b3 U6 D- o - txt = txt.Substring(0, txt.IndexOf("</output>"));5 ~6 H. g/ ]- I. \5 u* _
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)) I2 v0 g6 v! D9 o' `7 \9 F3 r
- {
( X- I; L. h: n& E. _: Z2 P - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
! I0 G/ p* g z s; j6 K2 w - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";# h' b9 c. t* z X/ E
- }
, v8 m; L: q3 X% G" X6 \ - else
+ R2 z/ L8 @+ Z - {
- z& H( @+ o/ w5 p. L - osd.spinTab.spinDoc.artf.Text = "";& U* h1 r: l( d- ]1 a4 U' g; x5 }
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
7 R# b/ r( \. D) U/ Q, T6 N+ H. @ - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";9 r& u8 n& s4 |
- }3 b: p# @5 U1 T$ w; i s% R. m
- }0 E! m5 r! {5 S! l6 O9 ]
- else if (txt.IndexOf("<error>") > -1)/ ~+ s1 W; P# ?% t0 h7 D: L
- {
2 Z; p2 j; n# @ - txt = txt.Substring(txt.IndexOf("<error>") + 7);7 P3 w, T$ K0 n. o% ^' A
- txt = txt.Substring(0, txt.IndexOf("</error>"));% n+ M1 m" h x6 i' E6 M
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);4 r0 U3 ], _/ o8 |8 q% N3 T
- }1 V# P9 J5 l; L/ v( n
- else
5 \, X% }8 |, U% L - {
l& c6 w1 K, } w% e" U8 Q - 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 p6 v$ u/ N6 P! H9 A k - 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, ""));% s. u7 K% e& ?$ X5 ^. ?7 ]
- }& r/ L% l, m* w& r6 Q' V2 o& a8 x; w
- }
: q" t) }. D2 _; F+ @
3 n+ P& c' ?: \- ]/ ?-
/ T" ^! q: X+ i/ X7 C2 c, C" E
' J. P$ U4 A( k/ X' H1 z8 h. v-
7 U1 U; [2 \, v/ L! b0 K2 A
6 g# E8 V2 L3 j- a2 J1 A- & }/ g5 r3 [" K3 h
复制代码 |
|