|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑
" [) I0 P+ l3 n: [5 O/ }7 {& ~zhangandma 发表于 2013-1-25 10:16 . `1 N R3 C; Z- w
发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的
+ j( ~4 K7 d( d. y3 t6 \1 ]因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。: P: d$ t4 L5 t3 G7 n
" L7 i Q7 p* \- q- K1 g: pstring 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)! f, X: M9 Z/ _" Z+ w3 i0 F
- {
5 ] z! e% d' k H5 g. q8 I - string selectedText;, \3 l! t* Q0 G, `
- IEnumerator enumerator;$ J# U, Y2 m6 |8 j' w0 @
- string str = "";
+ t6 M7 P8 j* W; o$ o! N# B - ArrayList list = (ArrayList) g_protected[g_projectedCategory];
4 q7 O) T8 t" Z, R - try
* E& ~$ h8 A* X; T6 i" X - {
3 ^: ]5 X4 J; ]* h2 \ - enumerator = list.GetEnumerator();, E; ?' }5 f0 I" w3 R
- while (enumerator.MoveNext())# f0 c1 E r2 C- c# y
- {1 g# c1 n5 P4 K# h% _
- string str4 = Conversions.ToString(enumerator.Current);8 x% \. W7 A1 Q! ^3 Q: H
- str = str + str4.Trim().ToLower() + ",";( H* S5 }# [( U$ {4 d
- }
5 q5 {$ `, r; ]( R - }
2 x1 ~: W- f0 W# L8 X3 Y. F% ^5 r$ Y - finally; N% K( ~- e3 K. |, u+ M
- {$ M' K2 O1 h1 J+ r4 E* h
- if (enumerator is IDisposable)9 v$ f2 P: t ~9 X' e/ _
- {- g" i7 j" `5 u& s; o- Z& c
- (enumerator as IDisposable).Dispose();
+ U$ B7 k& N9 e: z# l - }5 }, j1 k5 m* C
- }
2 s0 }3 d5 G: u - if (str.Length > 0)
0 J# }% [8 s$ I: h, F - {
6 ^3 ?/ |0 x( Q3 m1 c - str = str.Substring(0, str.Length - 1);
5 C$ M g l* c- D: c0 c' r - }; n5 O. S9 z" Y1 z$ y+ h
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)$ }, \4 u E, u4 |% y( h
- {
/ f* m* S! { | - selectedText = osd.spinTab.spinDoc.artf.SelectedText;
! C; T2 u; `4 F5 S8 p/ m - }
7 Q" y- z8 m+ Y5 ~ l. s9 ^ - else
, E) {4 \# \5 T$ Z4 c1 ?! k - {1 ?8 x" y+ s Q% u3 S# T5 |2 `
- selectedText = osd.spinTab.spinDoc.artf.Text;
% N8 b( }2 u5 }2 R+ ~ - }; b3 l! M5 C+ |8 J
- 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, ""));! I6 m5 N7 W5 J: m6 a) B Z6 w
- if (txt.IndexOf("<success>true</success>") > -1)) }' s6 }$ M! {) s: B, A
- {
7 v; F1 K# ^% A9 e! x d - txt = txt.Substring(txt.IndexOf("<output>") + 8);+ K# _3 Z2 |* {( z8 o4 O
- txt = txt.Substring(0, txt.IndexOf("</output>"));; S2 D& o/ f5 O/ D1 a
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
% C O7 e1 B7 h! | - {
; D+ n0 ^: r, X& D; Q# u - osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);5 \" @, C& a7 v0 H- Z& a
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";; k9 m3 I7 d' v4 p0 A# f
- }
* X0 W3 c5 t4 T9 c3 ^$ z; w6 X4 j) i - else
9 o" _1 [+ p7 p - {6 G% I/ Y9 E$ a3 c# q6 v
- osd.spinTab.spinDoc.artf.Text = "";/ H/ P. v, F5 O+ U$ q0 q) D
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);5 P; g/ m S X' y. K b* m
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";& K5 K! h) a- k! Y; i5 R
- }
/ i9 P9 L) S r( c, R0 ? - }
3 L6 y9 h! I& [: @: {; u$ y - else if (txt.IndexOf("<error>") > -1)9 j8 ]2 q# N+ F
- {) g- b8 { q1 A+ ^8 F. D2 b! F5 ]; T6 P
- txt = txt.Substring(txt.IndexOf("<error>") + 7);% M) [5 V3 K) E: r4 F
- txt = txt.Substring(0, txt.IndexOf("</error>"));7 I+ @! U, {' M- c( U
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
7 w, C2 k" X" p% i* F; i# M+ r! I& o2 ]( X - }
8 x8 ~: M/ l/ t - else
) p5 E2 B5 o- Z - {5 j) O I: [3 E' ?7 w) P2 C
- 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 n+ E" n4 l. j5 G$ x _
- 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, ""));
6 E, n$ n. C. S' b4 x* g - }
, B$ o* P) F, p3 B - }
* f' z$ @! v" m% D1 k% T Q - ; \8 M7 ?! e. p, |% {- k1 u) H
-
' R2 |5 @# T# g4 N& I - ' y$ i4 k @4 e" y
-
1 S- z1 |8 C# g. W A0 k1 s - & J; Z8 K6 b9 P- M7 [
/ E# Z6 Q" m3 A( k3 M4 J$ f
复制代码 |
|