NOTE: This question has been edited what was originally asked
I'm developing a windows service that, daily, queries a web service for data, compares that to currently existing data and then posts it to the client's webpage.
The code for the remote post executes fine, but updates never happen on the client's web page...
Imports Microsoft.VisualBasic
Imports System.Collections.Specialized
Public Class RemotePost
Public Property Inputs As New NameValueCollection()
Public Property URL As String
Public Property Method As String = "post"
Public Property FormName As String = "_xclick"
Public Sub Add(ByVal name As String, ByVal value As String)
_Inputs.Add(name, value)
End Sub
Public Sub Post()
Dim client as New WebClient()
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim responseArray = client.UploadValues(URL, Method, Inputs)
End Sub
End Class
I believe the reason for this is that the post generated by the above code is different to what the form itself posts manually.
Here's an example of a post generated by the above code:
POST http://www.thisdomain.com/add-event/ HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: thisdomain.com
Content-Length: 116
Expect: 100-continue
Connection: Keep-Alive
no_location=0&event_name=Cycle-Fix+MTB+Tour+-+3+Days+ABC&event_start_date=2013%2f04%2f06&location_state=Eastern+Cape
And here's an example of a post generated on the page itself:
POST http://www.thisdomain.com/add-event/ HTTP/1.1
Host: thisdomain.com
Connection: keep-alive
Content-Length: 2844
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://thisdomain.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary8u14QB8zBLGQeIwu
Referer: http://thisdomain.com/add-event/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: UTF-8,*;q=0.5
Cookie: wp-settings-1=m5%3Do%26editor%3Dtinymce%26libraryContent%3Dbrowse%26align%3Dleft%26urlbutton%3Dnone%26imgsize%3Dfull%26hidetb%3D1%26widgets_access%3Doff; wp-settings-time-1=1367827995; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_8d8e9e110894b9cf877af3233b3a007b=admin%7C1368089227%7C69a33748ee5bbf638a315143aba81313; devicePixelRatio=1
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="event_name"
test event
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="event_start_date"
2013-05-07
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="event_start_time"
01:00 AM
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="event_end_time"
02:15 AM
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="recurrence_freq"
daily
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="recurrence_interval"
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="recurrence_byweekno"
1
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="recurrence_byday"
0
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="recurrence_days"
0
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="location_latitude"
38.0333333
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="location_longitude"
-117.23333330000003
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="location_name"
test
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="location_address"
test
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="location_town"
test
------WebKitFormBoundary8u14QB8zBLGQeIwu
Content-Disposition: form-data; name="location_state"
Georgia
Clearly there's a lot more happening with the form's post than is the case with mine. Unfortunately, I'm afraid I don't understand all of it.
I have the following concerns about these differences:
- That my (apparently) querystring data is not being read because it's not being sent correctly ($_GET as opposed to $_POST)
- That there is possibly validation code in the PHP that saves the data after this post that is blocking it somewhere
Can anyone explain what exactly the differences here are and how I can emulate the form's post as per my requirement?