|
|
发表于 2013-1-25 10:20:15
|
显示全部楼层
本帖最后由 潜水大帝 于 2013-1-25 10:21 编辑 ( {4 k* `' m$ c! _4 D- t
zhangandma 发表于 2013-1-25 10:16 
8 a; n5 @* i+ C5 \7 C发过啊...我找的时候论坛里有下这个了..也是不支持Auto-Rewrite的 ) A: K3 L4 p, e1 b! C
因为Auto-Rewrite是要调用官方API接口的,这个提供的验证服务器上没有官方的API所以用不了。
0 t8 ~! y* v; c ]8 d* E0 ]( ]# Z e6 T h$ H# t
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)- @( Y7 r$ x% c9 @2 v+ O
- {
6 N2 N: K B4 ^ - string selectedText;! A( `( L: }( |/ c. }2 j& T$ c
- IEnumerator enumerator;
! @1 ?! o/ I5 r' j- N - string str = "";
- B/ u) S8 r4 F+ p z - ArrayList list = (ArrayList) g_protected[g_projectedCategory];3 j% G( ~8 D6 V+ z3 z
- try
) [! Q; C) l* p5 U - {
, _4 N2 K, k, _/ T6 U - enumerator = list.GetEnumerator();3 w! R- W4 ]6 g- |
- while (enumerator.MoveNext())
4 G5 w( e, x9 ]1 W: S - {- u+ s( ^1 B. G# ~( i
- string str4 = Conversions.ToString(enumerator.Current);" `% W1 U& S, h/ c1 ]
- str = str + str4.Trim().ToLower() + ",";5 ?; v3 k: J1 }+ t! g+ v
- }
/ M3 C# o1 ], F6 _# @ - }; l# _% n. }( X- Z
- finally
`& d q0 _, R( q - {' Z& V) ]7 F* n$ h! A/ W
- if (enumerator is IDisposable)
v2 a+ T) M: Z. P6 O - {4 p0 @# H5 k: N' r4 x
- (enumerator as IDisposable).Dispose();
2 H% e$ z5 }+ k6 q- J/ u - } k2 Z4 j4 |9 b0 v
- }7 l# W7 p. z. O# P/ O+ ^ @3 [ a
- if (str.Length > 0)
* _* x$ F Z/ Z$ n3 `- {% S - {- [& c2 Q3 ~) k) _/ Q
- str = str.Substring(0, str.Length - 1);
+ h4 \4 ]0 C! e6 |- \# A, X - }! X5 t% r" k% ? |; J0 C
- if (osd.spinTab.spinDoc.artf.SelectionLength > 0)* P* R2 ~8 |3 r
- {8 ]9 |- d& O5 p [9 I7 Y: \. ?8 `
- selectedText = osd.spinTab.spinDoc.artf.SelectedText;- [5 }! P0 [& c6 [
- }
2 V; B0 x& d- B2 ^9 m a$ s6 w - else
3 r: ?' H* m4 F1 ^4 V. ^( ^7 z - {$ ~% m# W; J: \# I- g9 j1 [
- selectedText = osd.spinTab.spinDoc.artf.Text;
9 u. ~! m" L0 l/ B2 E; F - }( r% @9 S" e9 l' Z4 C. 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, ""));. ^- W* l# T, H
- if (txt.IndexOf("<success>true</success>") > -1)
, [8 p! V# N( r# n: R - {
1 \% H. N* f8 S! W - txt = txt.Substring(txt.IndexOf("<output>") + 8);0 y: A( z+ r# N0 a8 {3 L6 F; E
- txt = txt.Substring(0, txt.IndexOf("</output>"));
$ W* N: V" x1 C - if (osd.spinTab.spinDoc.artf.SelectionLength > 0)
, B. I/ {0 K% l4 N - {! Q ^! t8 g7 J8 S$ A: }1 r
- osd.spinTab.spinDoc.AddCodedTextFast(txt, true, false, true);$ d' y4 P+ n- l* [# ?4 c
- MyProject.Forms.MainForm.status.Text = "Text was successfully rewritten.";
D1 D% s' t+ M9 \$ T9 m; M" I - }
4 P% i& F- h0 l9 v3 y- c - else Y6 U" Q4 h- N ^8 M; J1 |
- {2 p0 _) k* N+ s2 V) B; e9 n: P" B5 m& T
- osd.spinTab.spinDoc.artf.Text = "";; L& |# l1 L, ?' ?7 R
- osd.spinTab.spinDoc.AddCodedTextFast(txt, false, false, true);2 B7 z9 u- g: z+ ^: y
- MyProject.Forms.MainForm.status.Text = "Article was successfully rewritten.";
# n* {, P! C& V$ H {. j - }
$ k; }6 G; K! Q7 I3 B& w6 w# P - }
0 J" {. W0 o' t; W! m+ ^% o - else if (txt.IndexOf("<error>") > -1)
, m9 ]5 G, t! h$ G! A# w - {& x& ` c, y: N
- txt = txt.Substring(txt.IndexOf("<error>") + 7);( e: M9 Y+ A. ^ }. `: ?1 l
- txt = txt.Substring(0, txt.IndexOf("</error>"));
) {. a' e# u+ o- C - MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\n" + txt, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);3 T( l# W2 R, x3 t7 D9 O
- }
2 D# K3 w1 A' l4 Y2 O9 e - else2 b' h% e! Z) m2 S" I
- {9 J/ I9 _- V `1 X* T
- MessageBox.Show("An error occurred while attempting to rewrite this article:\r\n\r\nUnknown error. Empty result returned.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
: y# g! v0 l9 z+ H' G f2 _- A6 q& 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, ""));, l6 E# ^" y; m3 u; g
- }( V' G5 G$ ~; s% f5 i
- }$ x# Q" B0 ^- y" J
- 4 R, Y' q4 m9 {6 j' d
- ! V t& V$ O: e" W* W, R9 S
- 5 z' ?1 s$ u% S8 S
-
- p8 t1 D+ G6 g7 o( _ - - V+ }0 T/ U4 f6 x" \6 M
- 6 J0 \7 n6 p+ q8 I5 n* Z! e9 y
复制代码 |
|