|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
, P. l* S6 i" r7 vzhangandma 发表于 2013-1-25 10:16 + D0 F N& ]1 q
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 # s: e \0 n7 }: x, P
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。4 T, g# Z4 Q; E" E( d. f9 {& p
) \$ K y+ k4 b
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)+ S5 B# `) L% Z
- {8 K) Z% [& v. ^: j% Q
- string selectedText;
+ N2 n9 B: }2 h" w% g - IEnumerator enumerator;
/ j, x4 ~7 D4 e$ ]6 Z - string str = "";4 @- P4 T1 d8 J2 r8 {" ]5 n( b
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];5 E! n q$ n) d$ J" ]4 T
- try- ^# I) T3 V9 q, U) Z1 s, r1 V) Y
- {$ D9 [& Z3 ~8 O( G5 \7 S
- enumerator = list.GetEnumerator();
* J- z( h# c+ v - while (enumerator.MoveNext())5 y- r- O$ u- q5 x/ I
- {* I" f2 a7 B+ }* k: d* T
- string str4 = Conversions.ToString(enumerator.Current);% Q/ c$ R& G9 v
- str = str + str4.Trim().ToLower() + ",";% [) l; B, a3 W
- }3 {. H; b9 D0 w1 A/ W' }
- }
V0 O1 ], G1 L* T( i E - finally3 I* Y" I; X3 B/ f/ \* E# V; }
- {
- c% Z& }3 r6 q1 T4 ^% | - if (enumerator is IDisposable)1 G# F& N0 \- w' @
- {! Y3 L1 \3 B# x; o
- (enumerator as IDisposable).Dispose();
2 l: |7 y6 v* ^$ ]$ D - }
& {$ h' d- x6 U$ u* h2 a7 r s - }, X! m+ c8 ~9 {
- if (str.Length > 0)
0 a4 b9 r% u, z. c: @' d) n) f - {
# ^3 q% z% i1 i( H9 Q3 t - str = str.Substring(0, str.Length - 1);
0 y5 p+ m1 {/ w5 y% G) G9 u* \ - }: ]9 [! \) m7 c4 ~* X5 T
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
0 t5 r( S1 X9 ~4 N* C1 a& q - {8 ` X( p( U2 ?
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;9 z) e. V, C- D0 g% X* m/ ]+ r
- }
K( i/ m0 |8 e% ~1 o8 G! C - else
$ ]5 d! m- F) B3 I; z' I - {3 ?7 y9 Z9 ]. Q. |+ G/ C
- selectedText = osd.spinTab.spinDoc.artf.Text;
" M, W7 A2 V; ?/ \ - }4 t5 \+ @5 Z/ e1 v& \9 A+ h3 y
- 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, ""));
8 i6 e+ M5 _8 z: r* w. t - if (txt.IndexOf("<success>true</success>") > -1)4 Z* j: F4 L9 r' F) w. i9 u" Y
- {
" `1 Q! k2 c. W, ]6 e' } - txt = txt.Substring(txt.IndexOf("<output>") + 8);2 u+ X( N8 Y9 M( H+ `+ X
- txt = txt.Substring(0, txt.IndexOf("</output>"));
0 Y ?4 s6 Y* @. W8 P$ ]0 v - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
; B$ k) {' A; y9 t/ V - {
' S- w& v$ H$ y& P2 C9 H - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);( F( ~) O/ k y& l+ v
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";! e4 z9 K; F% s( Y
- }
& e; A7 m5 X8 W. n/ ]: d. A/ S - else
1 d7 H9 J- R. S& O; t, ], ` - {! j$ {; ?$ L5 D, n2 V$ w' e
- osd.spinTab.spinDoc.artf.Text = "";
8 ?" t3 C7 {( }, o) \- c- j. s - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);; s2 Q4 M0 Y% N+ u T
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
9 y7 s4 ] {" V0 g9 Q7 L% y+ Z - }7 z. p, c2 y. q$ Z2 Q
- }+ r. w2 i- O1 d a* A5 W2 g
- else if (txt.IndexOf("<error>") > -1)4 [7 W! Z. O" _* P" P+ M% E. k
- {
3 Y( B( P6 M+ w - txt = txt.Substring(txt.IndexOf("<error>") + 7);
" A, v B; f) z p7 L8 m( F - txt = txt.Substring(0, txt.IndexOf("</error>"));0 s1 l: ^% ~. {( }; q9 H
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
& _* }4 t/ k) a. M - }7 L3 W0 S0 B8 U
- else4 Q0 O' T. q3 d# R+ l; V
- {
* Y5 D. x; k2 E# E; y. D - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);3 o7 s4 F3 B/ d. h
- 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, ""));$ O3 ?2 B, I/ I5 m1 a
- }
$ p$ i9 g! c @& P; ~. y/ u - }% v4 v# C$ i" i) O9 d
5 d3 A5 J- n Y9 ~) u! R, n-
- A; B: w4 ^# _2 u - 0 F2 b+ c+ i5 r3 b' O& k8 ?
-
- e# d6 Q( t" y2 U - % O" P& v* d8 S$ k
- t! A+ x/ W" V/ d g* J* f
复制代码 |
|