|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
+ d3 F6 J, H% w4 y3 Jzhangandma 发表于 2013-1-25 10:16 
/ w- f( l4 v) h发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
9 j0 p1 c! J- \因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。# r9 O% v ]% i
- u5 ^/ G N6 a& X( zstring 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)
" I/ X. s; F( h$ X: s; U- x - {8 ?( n4 g/ I7 g" K
- string selectedText;% d9 F9 e" R$ _# Z! n' w: \
- IEnumerator enumerator;! v/ ~6 {9 Q3 E S: Q& I
- string str = "";
0 R: R* N! l5 N - ArrayList list = (ArrayList) g_protected[g_projectedCategory];" T* j7 ~! {/ i( [1 ~2 ~
- try
, b/ d* i% H1 W* U) r6 D( S$ k - {
7 |/ ^" e+ }& E2 k" o8 ` - enumerator = list.GetEnumerator();3 `4 a+ |2 |- g8 c
- while (enumerator.MoveNext())
6 [2 D( L# P5 ]6 R. x - {. j4 t( M3 n* {' k: o4 K$ d# u
- string str4 = Conversions.ToString(enumerator.Current);
/ w2 l8 R. K& i' R - str = str + str4.Trim().ToLower() + ",";
4 @2 @: k m& K2 O' T' H1 w - }1 R9 K* O, ?/ g% D
- }
" C& V$ L+ l$ y1 f1 X, \5 M - finally
( j4 `2 k% b$ H - { V% W3 h8 K* m8 T1 _
- if (enumerator is IDisposable)& d. r4 [" n1 P
- {, q* Y4 \2 L/ J' x5 a: D2 G; s6 d2 ?9 h
- (enumerator as IDisposable).Dispose();2 ~. T) P ]1 u5 K
- }- F, U4 E- z0 q, n8 H% C" D
- }
& t7 K6 g& M- n+ c4 c) ?8 L - if (str.Length > 0)
+ j& D5 e8 T7 v# |) X u - {
7 g+ X0 y) n- k - str = str.Substring(0, str.Length - 1);
+ W* x8 ~/ r5 j% w8 K - }( C2 N3 W* g1 ?& r3 H) R
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
5 G9 f2 Q% j6 n2 j( m( t2 T$ J - {& [3 s! C$ I2 ^& p% V
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;0 A7 y; {5 w7 ]# f! F
- }
$ L _, F1 g& p6 F* B% \# W; k+ D+ L - else5 s! F5 N3 h$ v. ]
- {7 z/ Q! _; R" s0 M& N
- selectedText = osd.spinTab.spinDoc.artf.Text;
4 u' u, K8 d1 A4 p: r1 v: a" h - }5 o" B3 I4 G! u$ T4 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, ""));! z& m6 o5 J5 x R! S* O! X3 c
- if (txt.IndexOf("<success>true</success>") > -1)
g" d" B4 P( q" \/ ^: C - {- M$ |8 q4 q4 @ E
- txt = txt.Substring(txt.IndexOf("<output>") + 8);5 ~) N m. |: N9 Y" ~& k
- txt = txt.Substring(0, txt.IndexOf("</output>"));
, \- b* h/ t8 y3 I7 I) d - if (osd.spinTab.spinDoc.artf.SelectionLength > 0). D4 H: e; B- {, D# `+ k8 }
- {
5 K: `+ V n% P; L0 p - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);
/ U1 k; ~% m D3 ^( A - MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
( f) q& M r* R# N - }. Z4 l b! Y7 R
- else
8 y- _) t5 U3 B9 U8 o$ Y y - {
$ k* e) e# b2 f& q) o7 J: ] d - osd.spinTab.spinDoc.artf.Text = "";
; r9 r9 G& b* k: Q: _7 u - osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);/ j4 Q9 A) j9 E! c( Y9 B& v
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";* S$ B" L( |" D9 r d
- }
3 F5 D. ^4 F c1 f7 X7 ^0 P - }
$ C$ e5 S! o- L# Y - else if (txt.IndexOf("<error>") > -1)
1 T- \0 w D7 o9 c5 _& m - {0 ]- z( [1 P/ q
- txt = txt.Substring(txt.IndexOf("<error>") + 7);
4 t- R$ Y, ~- M! j F/ `- X J - txt = txt.Substring(0, txt.IndexOf("</error>"));
2 A% T. o4 g1 B7 d3 h - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }5 V5 D: s1 ^2 `" y' M/ b - }9 G. W$ F ~6 e) F; V( A( _" H1 u
- else
* y$ y9 ^ ]! D7 q7 W - {5 `+ C* r/ y" i2 k
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);/ C8 x% m) B, r2 K% q* a* C
- 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, ""));
9 Y4 `8 [; o& L6 W - }4 V3 W0 x. Y, M! P v
- }
/ K0 L( g, [5 W8 j: D - 3 Z: I, H; K8 j1 w
-
6 K! L: [& v1 F; V: x2 p B - + _: A, j* z' S1 w& t
- " |3 T& p/ ~- Q: A2 Q' ?
- 9 }7 q/ ^. ]1 o" i) J7 w+ o7 D) Q
- 5 T; N: k# e5 k7 |
复制代码 |
|