![]() 圖01:新浪網(wǎng)注冊(cè)手機(jī)界面之一 |
![]() 圖02:新浪網(wǎng)注冊(cè)手機(jī)界面之二 |
![]() 圖03:新浪網(wǎng)注冊(cè)手機(jī)界面之三 |
這個(gè)口令要保留,下面發(fā)送短信就要使用這個(gè)口令。
三.本文程序設(shè)計(jì)、調(diào)試和運(yùn)行的環(huán)境:
(1).微軟公司視窗2000服務(wù)器版。
(2).visual studio .net 2003企業(yè)構(gòu)建版,.net framework sdk版本號(hào)4322。
四.visual c#實(shí)現(xiàn)短信息發(fā)送的具體實(shí)現(xiàn)步驟:
visual c#發(fā)送短信息的關(guān)鍵就是通過web引用新浪網(wǎng)提供的發(fā)送短信息的web service,并在引用完成后。調(diào)用此service的sendxml方法即可。以下就是visual c#引用web service發(fā)送短信息的具體實(shí)現(xiàn)步驟:
1. 啟動(dòng)visual studio .net。
2. 選擇菜單【文件】|【新建】|【項(xiàng)目】后,彈出【新建項(xiàng)目】對(duì)話框。
3. 將【項(xiàng)目類型】設(shè)置為【visual basic項(xiàng)目】。
4. 將【模板】設(shè)置為【windows應(yīng)用程序】。
5. 在【名稱】文本框中輸入【短信】。
6. 在【位置】的文本框中輸入【e:/vs.net項(xiàng)目】,然后單擊【確定】按鈕,這樣在"e:/vs.net項(xiàng)目"目錄中就產(chǎn)生了名稱為"短信"的文件夾,并在里面創(chuàng)建了名稱為"短信"的項(xiàng)目文件。
7. 把visual studio .net的當(dāng)前窗口切換到【form1.cs(設(shè)計(jì))】窗口,并從【工具箱】中的【windows窗體組件】選項(xiàng)卡中往form1窗體中拖入下列組件,并執(zhí)行相應(yīng)的操作:
四個(gè)label組件。
四個(gè)textbox組件。
一個(gè)button組件,其作用是發(fā)送短信息。并在這個(gè)button組件拖入form1的設(shè)計(jì)窗體后,雙擊它,則系統(tǒng)會(huì)在form1.cs文件分別產(chǎn)生這個(gè)組件的click事件對(duì)應(yīng)的處理代碼。
8. 把visual studio .net的當(dāng)前窗口切換到form1.vb的代碼編輯窗口,并用下列代碼替換form1.cs中的initializecomponent過程對(duì)應(yīng)的代碼,下列代碼作用是初始化窗體中加入的組件:
| private void initializecomponent ( ) { this.textbox1 = new system.windows.forms.textbox ( ) ; this.textbox2 = new system.windows.forms.textbox ( ) ; this.textbox3 = new system.windows.forms.textbox ( ) ; this.button1 = new system.windows.forms.button ( ) ; this.label1 = new system.windows.forms.label ( ) ; this.label2 = new system.windows.forms.label ( ) ; this.label3 = new system.windows.forms.label ( ) ; this.label4 = new system.windows.forms.label ( ) ; this.textbox4 = new system.windows.forms.textbox ( ) ; this.suspendlayout ( ) ; this.textbox1.location = new system.drawing.point ( 144 , 16 ) ; this.textbox1.name = "textbox1" ; this.textbox1.size = new system.drawing.size ( 184 , 21 ) ; this.textbox1.tabindex = 0 ; this.textbox1.text = "" ; this.textbox2.location = new system.drawing.point ( 144 , 69 ) ; this.textbox2.name = "textbox2" ; this.textbox2.passwordchar = '*' ; this.textbox2.size = new system.drawing.size ( 184 , 21 ) ; this.textbox2.tabindex = 1 ; this.textbox2.text = "" ; this.textbox3.location = new system.drawing.point ( 144 , 122 ) ; this.textbox3.name = "textbox3" ; this.textbox3.size = new system.drawing.size ( 184 , 21 ) ; this.textbox3.tabindex = 2 ; this.textbox3.text = "" ; this.button1.location = new system.drawing.point ( 152 , 256 ) ; this.button1.name = "button1" ; this.button1.size = new system.drawing.size ( 80 , 32 ) ; this.button1.tabindex = 4 ; this.button1.text = "發(fā)送" ; this.button1.click += new system.eventhandler ( this.button1_click ) ; this.label1.location = new system.drawing.point ( 56 , 24 ) ; this.label1.name = "label1" ; this.label1.size = new system.drawing.size ( 88 , 16 ) ; this.label1.tabindex = 5 ; this.label1.text = "注冊(cè)手機(jī)號(hào):" ; this.label2.location = new system.drawing.point ( 88 , 77 ) ; this.label2.name = "label2" ; this.label2.size = new system.drawing.size ( 72 , 16 ) ; this.label2.tabindex = 6 ; this.label2.text = "口令:" ; this.label3.location = new system.drawing.point ( 56 , 128 ) ; this.label3.name = "label3" ; this.label3.size = new system.drawing.size ( 96 , 16 ) ; this.label3.tabindex = 7 ; this.label3.text = "目標(biāo)手機(jī)號(hào):" ; this.label4.location = new system.drawing.point ( 96 , 176 ) ; this.label4.name = "label4" ; this.label4.size = new system.drawing.size ( 72 , 16 ) ; this.label4.tabindex = 8 ; this.label4.text = "內(nèi)容:" ; this.textbox4.location = new system.drawing.point ( 144 , 175 ) ; this.textbox4.multiline = true ; this.textbox4.name = "textbox4" ; this.textbox4.size = new system.drawing.size ( 184 , 48 ) ; this.textbox4.tabindex = 3 ; this.textbox4.text = "" ; this.autoscalebasesize = new system.drawing.size ( 6 , 14 ) ; this.clientsize = new system.drawing.size ( 410 , 303 ) ; this.controls.add ( this.button1 ) ; this.controls.add ( this.textbox4 ) ; this.controls.add ( this.textbox3 ) ; this.controls.add ( this.textbox2 ) ; this.controls.add ( this.textbox1 ) ; this.controls.add ( this.label4 ) ; this.controls.add ( this.label3 ) ; this.controls.add ( this.label2 ) ; this.controls.add ( this.label1 ) ; this.formborderstyle = system.windows.forms.formborderstyle.fixedsingle ; this.maximizebox = false ; this.name = "form1" ; this.text = "visual c#實(shí)現(xiàn)短信發(fā)送" ; this.resumelayout ( false ) ; } |
![]() 圖04:【短信】項(xiàng)目的設(shè)計(jì)界面 |
![]() 圖05:在【短信】項(xiàng)目中添加web引用的界面 |
| private void button1_click ( object sender , system.eventargs e ) { 短信.cn.com.sina.smsinter.smsws ws = new 短信.cn.com.sina.smsinter.smsws ( ) ; string result = ws.sendxml ( "sina" ,textbox1.text ,textbox2.text ,textbox3.text ,textbox4.text ,"new" ) ; messagebox.show ( result ) ; } |
新聞熱點(diǎn)
疑難解答
圖片精選