|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑 7 P; B( O0 N$ M7 h8 t& e% U3 A, D
zhangandma 发表于 2013-1-25 10:16 
5 a3 |- i& I1 z) B0 ~发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
( O9 c+ M) C( b9 B; \- b6 W因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
! f% s' D8 z8 ^( O' H# I1 ^+ H- ^& ^7 O# s' z# B- k
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)( o: q. B9 |1 p
- {
& m/ b: J' g! Y, ^' T! u - string selectedText;
4 o* y: ?- |& a) ^7 _9 @ - IEnumerator enumerator;" n. f5 y: h$ T* [' }
- string str = "";) {2 V2 X5 e/ C4 b$ t' U/ w( F5 a! x
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];2 h: F/ a i- c. m5 ]4 ?
- try
# ^% O3 \1 {( N4 f, @' X% C7 K - {: i! T7 t! \7 R( c+ j
- enumerator = list.GetEnumerator();! i5 M! z/ G! j1 m6 m2 S
- while (enumerator.MoveNext())
8 T* S7 Z8 n" z; Y. V% Y - {
0 K9 \. A# K- y' j - string str4 = Conversions.ToString(enumerator.Current);
/ S' g# \# J7 x - str = str + str4.Trim().ToLower() + ",";
5 R- a' K9 S) C* v$ [* i - }
$ r: u6 U; N6 P- y - }
+ R7 w4 [% r$ l! e F - finally( s; B( |9 l' {. M. l4 k6 K+ ?; E
- {
. A v% V/ {7 ?+ ^6 b5 b& J - if (enumerator is IDisposable)" f+ `- x( S8 w( }+ r* f* e$ c
- {
2 R, H9 V1 P2 s2 v0 D; X - (enumerator as IDisposable).Dispose();
; H" Z% j. g% P$ L6 k' _ - }
. n3 \5 w/ d b, u& }" f6 G+ B' q1 V - }6 [8 j2 D! g# G# E* {% g
- if (str.Length > 0)
8 X, ?; V5 B7 w+ x4 } - {- x0 T7 R" M: l6 T9 ~
- str = str.Substring(0, str.Length - 1);
- O' P, F0 l, D$ Q3 r( L - }0 p" u* }* D; u8 L' p b) e
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
& d+ l9 f4 h) \ - {+ J0 T# O/ w- a$ @' M2 A/ p6 T
- selectedText = osd.spinTab.spinDoc.artf.SelectedText; q# x( D' u' A% n
- }8 g, i: Y9 [6 D& P8 k0 y+ l1 e
- else
6 Z: \8 A! t/ p, I - {
/ T! [' ?' s- z9 I6 y - selectedText = osd.spinTab.spinDoc.artf.Text;
% ?6 F; v1 T6 `8 P; k - }
1 }- }- ]; |5 L - 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, ""));
- }) g4 U7 I# z+ k- S5 M7 w - if (txt.IndexOf("<success>true</success>") > -1)
, |% I2 _0 q& E! I$ D - {' O9 Q, j" ]# p9 {& _6 a2 B
- txt = txt.Substring(txt.IndexOf("<output>") + 8);7 f+ o4 M" c! w
- txt = txt.Substring(0, txt.IndexOf("</output>"));
0 Y& u- G, |( _, o5 t) a - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)1 M9 o$ v6 j6 w4 t# i8 G3 r
- {9 D* @; S# q5 P. D
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);$ i7 D/ B9 h. I5 X/ a9 s( ^$ L0 I u! h
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
4 v3 @* X5 k2 d - }
; v! ]# @# j$ Q+ ^6 N - else ]* E' f- J. t7 ]+ T3 _( X/ }
- {0 V, Q$ k# Z2 \
- osd.spinTab.spinDoc.artf.Text = "";
8 d* W9 A0 o: u5 B* J - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);; \8 @0 ]9 X0 J2 v3 R
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
1 E: N/ P. g* ~* Z; F - }) M, S* u4 m! b c1 O9 x; U! F
- }- d8 k! R$ }, Y( a$ C6 g
- else if (txt.IndexOf("<error>") > -1)
! z4 ?* z7 j1 Q/ L - {. p1 f! |' q3 S& @' _2 j
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
6 u9 ?+ {) x# b5 }/ g - txt = txt.Substring(0, txt.IndexOf("</error>"));% O& _4 \7 b# \
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);; Q4 I8 r4 T2 P! z; I
- }+ k8 Y, l! }3 l# i
- else4 v& n% G- ]; |: w' G" u! g8 j
- {$ I [8 L. G$ ~+ ?
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);) t5 m9 P6 m1 T
- 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, ""));1 q% H% T( n' D E( D2 J
- }/ _' J9 o) t( K& k- m: v& l
- }
1 W* N: {$ Q* k1 e: S) s
+ X, y0 |; O }8 ~/ `9 [/ e( R- ) ?. o2 [3 h0 n& D3 a
- " K) ~5 N" x4 j1 I6 ^
-
! @( T7 J2 r6 r- k
) ]8 S( R4 Q: P, s1 ^ s
; ~4 w1 }3 g( V
复制代码 |
|