2013-01-02 25 views
0

行,所以我在噸後在這裏和其他地方看看。我有什麼是這樣的PHP腳本。HTTP POST不是WP7工作,不發送名稱字段超過

<?php 


//gets the post from the phone app 
$calendar = $_POST[ 'calendar' ]; 

//converts the post into a string for manipulation 
$xml = simplexml_load_string($calendar); 

rest of code omitted 

然後在C#我有這個

string Event_xml; 
Event_xml = "<?xml version='1.0' encoding='ISO-8859-1' ?><calendar><event><event_id></event_id><title>"+ local_title +"</title><venue_id>1</venue_id><contact_id>1</contact_id><description>"+ local_description +"</description><category_id>1</category_id><user_id>" + local_ID + "</user_id><group_id>1</group_id><status_id>1</status_id><date>" + local_startDate + "</date><starttime>" + local_startTime + "</starttime><endDate>" + local_endDate + "</endDate><endtime>" + local_endTime + "</endtime></event></calendar>"; 

WebClient wc = new WebClient(); 
var URI = new Uri("http://jasonsftp.no-ip.info/test/EventInput.php"); 
     wc.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 
     wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted); 

     wc.UploadStringAsync(URI, "POST", Event_xml); 

,當我得到的迴應背上它是錯誤

注意:未定義指數:日曆的htdocs \測試\ testinput.php第11行 Array 注意:嘗試獲取第30行的htdocs \ test \ testinput.php中的非對象屬性

警告:無效參數supp謊稱爲的foreach()在htdocs中\測試\ testinput.php上線30

現在如果我用一個標準的HTML後是這樣的:

<form action="http://jasonsftp.no-ip.info/test/testinput.php?" method="post"> 
     <input type="text" name="calendar" value="mydata" /> 
     <input type="submit" /> 
    </form> 

它工作得很好。 所以名稱=「日曆」是在C#中不能用我當前的代碼去了解。

任何幫助,將不勝感激。我希望這不是很複雜。我想我只是錯過了一些東西,但是在閱讀課程描述時我沒有找到任何東西。

感謝 傑森

回答

0

所以我找到了在這裏工作是我曾在C#

WebClient wc = new WebClient(); 


     string sendData = ""; 
     var URI = new Uri("http://jasonsftp.no-ip.info/test/testinput.php"); 
     wc.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 


     sendData += "&title="+local_title; 
     sendData += "&event_id="; 
     sendData += "&venue_id=1"; 
     sendData += "&contact_id=1"; 
     sendData += "&description=" + local_description; 
     sendData += "&category_id=1"; 
     sendData += "&user_id=" + local_ID; 
     sendData += "&group_id=1"; 
     sendData += "&status_id=1"; 
     sendData += "&date=" + local_startDate; 
     sendData += "&start_time=" + local_startTime; 
     sendData += "&end_date=" + local_endDate; 
     sendData += "&end_time=" + local_endTime; 

     wc.Headers[HttpRequestHeader.ContentLength] = sendData.Length.ToString(); 
     wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted); 

     wc.UploadStringAsync(URI, "POST", sendData); 

和這裏的PHP做的是我做過什麼,使其工作

<?php 

$title = $_POST['title']; 
$event_id = $_POST['event_id']; 
$venue_id = $_POST['venue_id']; 
$contact_id = $_POST['contact_id']; 
$description = $_POST['description']; 
$category_id = $_POST['category_id']; 
$user_id = $_POST['user_id']; 
$group_id = $_POST['group_id']; 
$status_id = $_POST['status_id']; 
$date = $_POST['date']; 
$start_time = $_POST['start_time']; 
$end_date = $_POST['end_date']; 
$end_time = $_POST['end_time']; 
$latitude = ""; 
$longitude = ""; 

與我能夠從手機得到的值,並根據需要將它們添加到數據庫中。