|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑 9 U1 E" u8 e$ H2 X3 g" I
zhangandma 发表于 2013-1-25 10:16 + @; q. C# X9 l& A$ ~
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 1 k5 | x$ J1 d1 {) y
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
! n1 A- x% \6 V% G6 r7 f
5 X8 s s% f! |2 @& V$ Y5 ]0 dstring 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)
$ M2 Y6 S/ \0 y$ Y$ t* F( l - {
, Q7 G8 n$ Z. n4 o0 f - string selectedText;: p) d! I% Y+ ] j& r' {) ?( T! S' c% h0 k
- IEnumerator enumerator;+ N' c- U+ w, G# K# w
- string str = "";
5 R8 a' x, Q6 ?$ r5 i; L& m - ArrayList list = (ArrayList) g_protected[g_projectedCategory];
! |* i* T( V9 h2 q7 L - try
3 _! O& q0 P1 B3 ?! R - {" @* h* \$ l* O- K, U+ x6 M+ \
- enumerator = list.GetEnumerator();- g1 W2 x1 W- ~
- while (enumerator.MoveNext())
5 P7 V6 ^& Z; u - {
* U. @" L" a) ?% e* ~7 T - string str4 = Conversions.ToString(enumerator.Current);, A4 g- P( \! x/ S
- str = str + str4.Trim().ToLower() + ",";
+ \6 q1 p5 w9 x9 g1 h; d - }4 A: G3 ]# U( t& c) U% ~
- }
3 Z, t& U# F7 y) F/ \. R0 a - finally
e/ y1 @, z1 ~6 H - {
3 A* d; ?: j! b% d0 S/ n7 L4 C - if (enumerator is IDisposable)9 t# s5 `. @ T% {. ~# X: _
- {
: s. e+ N) s) C/ G9 } v - (enumerator as IDisposable).Dispose();9 D ]: o# o6 |" i! s# y* \
- }; z; Q0 k2 R* s
- }& |4 K* K! J7 s: b0 Z8 P" t7 P
- if (str.Length > 0)5 t* p9 i: p1 L! A
- {) f9 u5 y f1 D9 C
- str = str.Substring(0, str.Length - 1);3 C U! A- E& {, p% E0 o+ x
- }
/ ^9 G- |8 M( l _1 n - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
- X) p }9 z( h0 T: [) q% B - {
% |! i5 K) {8 R! n* w. s - selectedText = osd.spinTab.spinDoc.artf.SelectedText;; m0 i5 R; v% v
- }- l" ^' r7 J) e* P# u. v
- else) N2 Y! q9 S, x: K z
- {$ R3 j/ U* J# n0 Y, {9 E* C
- selectedText = osd.spinTab.spinDoc.artf.Text;1 b; r6 m# Q- o1 x0 o& r6 U, G; I
- }' e9 v l v. G& z. H
- 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 U, h6 H0 |) z9 E" [( g - if (txt.IndexOf("<success>true</success>") > -1)
2 K+ W7 h/ ~! q. }, I - {- O' } I% s* u7 ], Z8 L" J: F* C" V
- txt = txt.Substring(txt.IndexOf("<output>") + 8);
+ Q5 U" R. l, f- {; |4 H - txt = txt.Substring(0, txt.IndexOf("</output>"));
0 a1 v: D/ p+ t7 D" ^' v/ z1 Y - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)( e4 `# s- R9 n5 P$ U
- {
2 j; f: A# Y3 c+ @- C - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);, `& x! J) V/ g9 _ x
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
e* t% }+ [9 @2 ^) |3 t4 A S - }, L3 L2 H$ E% p# I, X( k' t
- else
; Q) a! m" ^( b& R: H - {9 F J _' b9 }# T
- osd.spinTab.spinDoc.artf.Text = "";% Y4 |3 b- w, L" l6 O. u' ?
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);3 b+ @* D8 }; M9 r" n
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
; A9 m0 e% Y1 K* [ - }
! z' x7 { W! U# R/ Y8 X - }& \' D! @' l ?/ a3 l( Z
- else if (txt.IndexOf("<error>") > -1)
Q) ^# [5 q0 _; K0 t - {7 d% ~9 n1 g0 N7 v' |" C: z9 W8 f
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
`$ F' D5 X+ V. p4 R1 K - txt = txt.Substring(0, txt.IndexOf("</error>"));( Q* q: g1 @' w+ \& o3 m
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
8 t) r- Q+ _. o8 \+ C$ ] - }
. C! {$ d& |" n2 ~ - else' V; O- W2 \% B* Q5 l4 T
- {
) d% i/ [& o" ^- _ - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);+ {" o- ]+ ~/ }- ^# n% H% q
- 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, V8 r; J9 V* [( `- y2 D) b
- }
( d6 D" [3 e. i z* t - }
/ H3 G) I9 f# j5 u1 C1 t - / R7 ^" q( t; N0 B, o D0 [
- $ e& Z; S5 p0 w( K( R
- ; G: A7 a, u3 J& B+ m
-
3 @0 l7 t0 E# T+ D8 X& | - 4 X4 ?# [7 J* [
G( h1 y6 L+ u0 O5 G) y* m
复制代码 |
|