1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SubmitData();
}
private void SubmitData()
{
try
{
string subject = textBox1.Text; // textBox contenant le titre ^^
string message = richTextBox1.Text; // RichTextBox contenant le message ^^
string topic_cur_post_id = "109"; // Input type Hidden représente la valeur de l'id du dernier post ajouter
string lastclick = "1305669176"; // Input type Hidden mais sans grande valeur car si modifié avec firebug directement sur le form cela fonctionne quand même...
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "subject=" + subject + "&message=" + message + "&topic_cur_post_id=" + topic_cur_post_id + "&lastclick=" + lastclick;
byte[] data = encoding.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1/phpBB3/posting.php?mode=reply&f=3&sid=628549786d786dc2a8f1b7705c71b6fd&t=104");
request.Method = "POST";
request.Host = "127.0.0.1";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.KeepAlive = true;
request.Referer = "http://127.0.0.1/phpBB3/posting.php?mode=reply&f=3&t=104";
//request.ContentType = "application/x-www-form-urlencoded"; OU ???? "application/octet-stream"
request.ContentType = "application/octet-stream";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
WebResponse response = request.GetResponse();
stream = response.GetResponseStream();
StreamReader sr = new StreamReader(stream);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}
}
}
} |
Partager