Just finished an automatic newsletter-subscriber module written in C#. Now I have to translate it in PHP so I can use it with my wordpress sites as well. I'm not that good in PHP as most of the time I'm writting .NET MVC applications. In C# I came up with the following solution:
// Code below runs each time a user submits the newsletter form
using (var client = new WebClient()) {
var MyValues = new NameValueCollection();
MyValues["list"] = "123456789";
MyValues["boolean"] = "true";
MyValues["name"] = model.NameSec;
MyValues["email"] = model.EmailSec;
var MyResponse = client.UploadValues("http://www.XXXXXX.com/subscribe", MyValues);
var MyValue = Encoding.Default.GetString(MyResponse);
if (MyValue.Equals("true")) {
// All correct
}
else {
// Oops, smth went wrong
}
}
Now I'm looking for a similar method as WebClient.UploadValues
but for PHP. Could you please give me some guidance?