|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
1 `9 Y0 M* H2 K1 p2 I3 Q Ozhangandma 发表于 2013-1-25 10:16 4 }6 }3 u8 B5 }- F6 R
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 6 {8 \' h2 m. M8 |
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
- m1 S: `6 M$ x4 b& d+ j2 R4 j- D
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/ w3 D5 [! o7 o9 j7 b - {; o# a, H# l7 ^3 G1 A: g5 [
- string selectedText;
; d4 U' N7 ^3 d: e% O - IEnumerator enumerator;/ }, ]9 O& X2 `
- string str = "";) Q" S. N# `8 n& V/ x
- ArrayList list = (ArrayList) g_protected[g_projectedCategory];' a6 v8 z$ l- l- f
- try
7 q) X) B- p7 k+ `# ~' r - {9 Z! L6 x. s- R/ Z. L) R$ x
- enumerator = list.GetEnumerator();
- ?7 b% F3 m4 H" W. F) c - while (enumerator.MoveNext())
7 H( C( _. C) R5 Y# U7 M' k' L% Y - {2 [' y% F- w. m& |: ], q t0 u
- string str4 = Conversions.ToString(enumerator.Current);7 I" H) u& @9 f- }! F; _
- str = str + str4.Trim().ToLower() + ",";. Z, k$ v% ~/ B
- }
* D( @% ~5 r; i - }" ?* g, Z3 A0 [( M }! M4 c( p
- finally5 ^$ V" y1 T! U, U V4 ?1 b' m
- {+ S) k, [; D; l/ w
- if (enumerator is IDisposable)6 b6 D* |9 g" V; Y4 N' J: p
- {
7 _# a6 _0 ~% q: \* D: H - (enumerator as IDisposable).Dispose();
+ i2 s/ q; @- B9 F: Q - }
5 i9 K4 C k1 J& g0 w! d4 { - }
1 y: y- z& v- H7 x - if (str.Length > 0)
$ r9 G" p& m* \& X- T( ?1 A - {0 ?' M9 c6 W0 b w/ E/ a. `( E
- str = str.Substring(0, str.Length - 1);' d# I! Z7 B- W$ s
- }
$ ?% C: @# Q" u+ J- f8 R - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
( d; D9 t9 U. b$ e" m - {
" {9 F0 ^3 B. L: p( I& L. x - selectedText = osd.spinTab.spinDoc.artf.SelectedText;" o. a% [) x- O$ E
- }
: d& d5 M# ]5 o i- B6 e+ Q' s, Y. q - else
( Q$ b' I/ U; c5 z$ m) K5 K$ i - {
) S5 i3 Q$ ]$ y: l - selectedText = osd.spinTab.spinDoc.artf.Text;
1 w% b1 I2 v/ Q3 E1 B, L - }7 T! {* G& H2 `$ U' |/ ^3 x
- 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, ""));# N0 R" t7 R* O( t. ]
- if (txt.IndexOf("<success>true</success>") > -1)
$ m: P+ x6 h3 r+ X0 F" x. C3 r - {* s. E9 s: v( X2 V* {( t
- txt = txt.Substring(txt.IndexOf("<output>") + 8);3 n$ m! f- _9 Z" F" g% ]$ r
- txt = txt.Substring(0, txt.IndexOf("</output>"));! @& F$ H5 z( {0 e
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
! l* h2 G, Q9 f) H' V9 T - {
% ? p, U, x1 p6 e5 H! R# [# T - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);6 w6 x; F0 i; H- g8 r. p0 b
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
; C3 a$ Y1 o& d1 r' Z! d( z - }
/ V; P- f& V. @& x! T( Q% Y5 ` - else
8 [2 m2 J2 f" Q& } - {
' _2 b, Q/ A% F8 T3 k1 y; ] - osd.spinTab.spinDoc.artf.Text = "";
# ~3 h0 r! n" [5 Z - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
) @: M: \3 n* U8 I - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
: v0 t* m9 U, q3 {7 r; N/ {5 A - }9 \1 M. P- Y0 M5 g$ \2 W, K. u( h) ?
- }7 m. x6 Q8 }+ l: [% w6 D
- else if (txt.IndexOf("<error>") > -1)
1 A# _ P% {" _& B* K - {4 W* l' w/ f$ h
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
/ ]) @% d! C C. ]" A q( m0 K - txt = txt.Substring(0, txt.IndexOf("</error>"));
. V) D6 X7 G# ` - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
5 ?- I3 A, [5 ]& y$ Y5 D5 R - }
. i3 L& u- O3 U# K& \ - else6 B+ s g' r8 F* w; J
- {' B0 x4 H8 o8 p `2 G$ \8 U
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
9 }5 e6 f4 t; l: @! j - 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, ""));5 x9 h) m0 y+ q+ C
- }
$ g8 y. h2 ?! ? - }
) t8 Q% F% `$ z
2 I) Z: I: ]3 W& i-
# |9 U5 T/ }: B' `/ i/ e
! S: v) |( }9 G* `7 l) J-
1 U# G% K$ b5 V2 l$ S - / p v( B+ X" `6 D+ c
- 6 I* Z1 D f' B9 d* O" Y$ r
复制代码 |
|