|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
1 h: L9 E% v1 m- k' ~7 Q( Tzhangandma 发表于 2013-1-25 10:16 
0 ]6 F, x2 x' V2 Z发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 % u* X- W1 a0 _+ [' ? j& ^
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
( M* Y: S; \( f; J8 {3 c' Q2 z* A1 k7 z" R' R8 a
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)
* v7 |2 K, \1 ^ v* ] @4 s3 P# {: N - {
* J0 X. [2 N& p+ c3 z% Q! N - string selectedText;
- u* N& O/ h, S; _* y - IEnumerator enumerator;
' M c- p3 o5 I8 i - string str = "";
A1 A$ o. x, ?. \) F: w - ArrayList list = (ArrayList) g_protected[g_projectedCategory];
7 t" g n9 o1 a' @7 V - try Q* r- c2 @" L w- z
- {
" b- u1 i: `. f/ O- W* Y3 T; Q - enumerator = list.GetEnumerator();
5 [* i! ~8 f4 ]" ~5 A2 U - while (enumerator.MoveNext())1 t- H) g% d+ i: d8 e5 v
- {
5 {9 i7 N% P" r z& z# q - string str4 = Conversions.ToString(enumerator.Current);9 |$ T1 s3 [4 c& }/ A
- str = str + str4.Trim().ToLower() + ",";
9 G( @) O- G. ?# B# H5 C8 J - }7 y7 ~+ }6 t$ f
- }4 m7 Z0 w. y' B4 M7 j4 l
- finally$ d7 z& N+ D5 O8 v0 c6 P6 Y
- {
6 |% T/ s* S& l/ w T9 b+ m( \" e - if (enumerator is IDisposable)! b+ I4 n4 p4 W$ u3 Q+ ^; w
- {
* d9 j" E8 @8 i( N+ w- c - (enumerator as IDisposable).Dispose();
( A7 F5 C% d( d" s - }
% U! W" |( E- M5 C - }
/ R# T- S+ M$ D- y9 C- q - if (str.Length > 0)
/ Z: C8 Y2 j+ T" S& x1 R1 m - {
3 N' C& C" [2 _5 O% h q7 K - str = str.Substring(0, str.Length - 1);
# ?, f, U( V3 g3 } - }
! S" B: z% K$ j9 |% W - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
8 X. _" x/ ?0 u+ [' g1 h - {
; o# s6 @( i6 x# [ E( e# R - selectedText = osd.spinTab.spinDoc.artf.SelectedText;
" `3 H) p5 q, R/ E. _$ F: `) f - }; G l( h- \; R; i& {8 @
- else
# ~- k: h% O. k, \8 E9 R - {' q. }% z1 F t! {/ s8 O
- selectedText = osd.spinTab.spinDoc.artf.Text;
& V6 j+ V) P7 Y% A7 \; J - }
/ K; A' k7 r- \# y; 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, ""));
. p$ }$ a8 |; x: n - if (txt.IndexOf("<success>true</success>") > -1)# o6 C; j( q$ [ X
- {
! `0 n4 ~4 a- T' G9 t. B$ Q - txt = txt.Substring(txt.IndexOf("<output>") + 8);
, W& w% \6 ^7 T; a8 \ - txt = txt.Substring(0, txt.IndexOf("</output>")); }5 i" |; A& e7 ^# `0 _0 D
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
8 A% i7 I# d% N/ i3 j - {( x! P& D. a& @2 e) O1 O J
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);' [* R7 c: E% D4 g
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
+ f5 S! v, Z: v% | - }
0 E, N* h$ q }& @# t s, B - else
6 v0 x) r( A( Y - {
3 l3 r. T: a" Q% A6 w$ p8 \ - osd.spinTab.spinDoc.artf.Text = "";
( G* P: h9 t9 x @! H: E - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);
3 V' ~. U9 V! H* @4 i - MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";+ a @ e0 m$ X; f# l _
- }
+ q; t- {2 V6 U# c5 h% G: d - }
/ u3 w0 t- s1 x9 f# X - else if (txt.IndexOf("<error>") > -1). e$ c; u1 S+ m( i& p; ]
- {* R l) L& l+ ?
- txt = txt.Substring(txt.IndexOf("<error>") + 7);- w) ~3 O/ b2 Y! Y0 b
- txt = txt.Substring(0, txt.IndexOf("</error>"));
; I- u5 |7 S- ~8 {5 g4 o* w, {. B - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
* B! Y H9 y6 _5 g. G3 b - }
3 N! X8 N! I9 _ - else
$ l d+ I& q9 P" ` - {3 y; T' G% k1 Q5 A2 y$ H. Y
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);# a: [" m1 g# q$ s( ?1 z4 n
- 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, ""));
* H/ | y( s2 Z- D$ U: L - }0 |+ H% h3 X2 p' w5 W, u) g) D
- }5 K" R: }8 F$ C% J( l
+ t: B* L$ `3 w( R-
+ Z& N7 @' v- T1 | - : e! s3 T' e- M, |! d
- - ~1 P |- U/ C# R; [
, j+ l# S# K' P
- M; Y I0 E9 T( h! r7 @
复制代码 |
|