'OLD POSTS'에 해당되는 글 56건
- 2012.11.28 2012년 11월 UDK 릴리즈 노트 중에서.
- 2012.11.27 Setting Up Configuration Files for a New Game Project
- 2012.04.26 PHP에서 json post 를 처리하는 방법.
- 2012.04.26 [C#] HttpWebRequest 클래스를 이용한 POST 전송하기.
- 2011.02.04 Fonts for ipad, iphone
- 2011.01.07 WPF의 datagrid 의 스타일 정의.
- 2011.01.04 PHP 에서 UTF-8 관련 문제.
- 2010.12.29 Stencil Routed K-Buffer
- 2010.12.26 Tile Map Editor
- 2010.12.22 OpentTK/WPF integration
2012년 11월 UDK 릴리즈 노트 중에서.
New Perforce Setup Wizard
- Developers using the Perforce integration can walk through setting up a new Perforce server via the UDK installer.
Clean Starter Project Tool
- Developers now have the option to start with a “clean” project with bare minimum code and content upon install.
- This is a great way to begin development of a new game from scratch!
'OLD POSTS' 카테고리의 다른 글
Perforce Server 유저 자동 생성 막기 (0) | 2012.11.28 |
---|---|
unrealscript mobile previewer debugging (0) | 2012.11.28 |
Setting Up Configuration Files for a New Game Project (0) | 2012.11.27 |
PHP에서 json post 를 처리하는 방법. (0) | 2012.04.26 |
[C#] HttpWebRequest 클래스를 이용한 POST 전송하기. (0) | 2012.04.26 |
Setting Up Configuration Files for a New Game Project
http://wiki.beyondunreal.com/UE3:Setting_Up_a_New_Game_Project_Tutorial_(UDK)
http://wiki.beyondunreal.com/UE3:Setting_Up_Configuration_Files_for_a_New_Game_Project_Tutorial_(UDK)
UDK 로 새 프로젝트 생성시 추가해야할 것들.
'OLD POSTS' 카테고리의 다른 글
unrealscript mobile previewer debugging (0) | 2012.11.28 |
---|---|
2012년 11월 UDK 릴리즈 노트 중에서. (0) | 2012.11.28 |
PHP에서 json post 를 처리하는 방법. (0) | 2012.04.26 |
[C#] HttpWebRequest 클래스를 이용한 POST 전송하기. (0) | 2012.04.26 |
Fonts for ipad, iphone (0) | 2011.02.04 |
PHP에서 json post 를 처리하는 방법.
How to Handle JSon POST Request Using PHP
http://edwin.baculsoft.com/2011/12/how-to-handle-json-post-request-using-php/
On my last project, i need to create a php service using JSon to handle service requests from multiple clients. My PHP file would consume JSon string for its requests and produce JSon string as its responses.
Im not too familiar with PHP, but after sometime googling i’ve found a workaround. This is how i do it.
This is the http header and body of request and response.
Hope it help others, have fun with JSon
지난글에서 C# 으로 post json 데이터를 날리는 경우에는
Content-Type 가
application/x-www-form-urlencoded
인 경우에는 $_POST[postData] 로 받아서 처리하면 되는데.
Content-Type 자체가
application/json
인 경우에는 php 에서 위와 같이 처리한다.
'OLD POSTS' 카테고리의 다른 글
2012년 11월 UDK 릴리즈 노트 중에서. (0) | 2012.11.28 |
---|---|
Setting Up Configuration Files for a New Game Project (0) | 2012.11.27 |
[C#] HttpWebRequest 클래스를 이용한 POST 전송하기. (0) | 2012.04.26 |
Fonts for ipad, iphone (0) | 2011.02.04 |
WPF의 datagrid 의 스타일 정의. (0) | 2011.01.07 |
[C#] HttpWebRequest 클래스를 이용한 POST 전송하기.
01.
protected
void
SendSMS()
02.
{
03.
String[] messages =
new
String[6];
04.
messages[0] =
"행정과"
;
// 아이디
05.
messages[1] =
"암호"
;
// 암호
06.
messages[2] =
"11111111111"
;
// 보내는 사람 번호
07.
messages[3] =
"22222222222"
;
// 받는 사람 번호
08.
messages[4] =
"테스트 메시지"
;
// 메시지
09.
messages[5] =
"홍길동"
;
// 받는 사람 이름
10.
String postData = String.Format(
"id={0}&pw={1}&sender={2}&receiver={3}&msg={4}&idreserve={5}"
, messages[0], messages[1], messages[2], messages[3], messages[4], messages[5]);
11.
12.
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(
"http://localhost:38080/encoding/encoding.jsp"
);
13.
// 인코딩 1 - UTF-8
14.
byte
[] sendData = UTF8Encoding.UTF8.GetBytes(postData);
15.
httpWebRequest.ContentType =
"application/x-www-form-urlencoded; charset=UTF-8"
;
16.
// 인코딩 2 - EUC-KR
17.
//byte[] sendData = Encoding.GetEncoding("EUC-KR").GetBytes(postData);
18.
//httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=EUC-KR";
19.
httpWebRequest.ContentType =
"application/x-www-form-urlencoded; charset=utf-8"
;
20.
httpWebRequest.Method =
"POST"
;
21.
// Set the content length of the string being posted.
22.
httpWebRequest.ContentLength = sendData.Length;
23.
Stream requestStream = httpWebRequest.GetRequestStream();
24.
requestStream.Write(sendData, 0, sendData.Length);
25.
requestStream.Close();
26.
HttpWebResponse httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
27.
StreamReader streamReader =
new
StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding(
"EUC-KR"
));
// Encoding.GetEncoding("EUC-KR")
28.
string
html = streamReader.ReadToEnd();
29.
streamReader.Close();
30.
httpWebResponse.Close();
31.
32.
text.Value = html;
33.
}
This is an easy way to make a JSON POST request to a remote service using C#:
1 2 3 4 5 6 7 8 9 10 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST" ; request.ContentType = "application/json; charset=utf-8" ; DataContractJsonSerializer ser = new DataContractJsonSerializer(data.GetType()); MemoryStream ms = new MemoryStream(); ser.WriteObject(ms, data); String json = Encoding.UTF8.GetString(ms.ToArray()); StreamWriter writer = new StreamWriter(request.GetRequestStream()); writer.Write(json); writer.Close(); |
Notice that in line 4 we create an instance of DataContractJsonSerializer (Assembly: System.ServiceModel.Web) and initialize it with the type of object we are serializing as JSON to send to the service. In lines 5 and 6 the serializer writes the object into a Stream. Line 7 transforms the Stream into an UTF-8 String (as the content-type) and finally in lines 8 to 10 we send the data to the service.
약간의 문제가 발생하게 되는데
x-www-form-urlencoded 방식의 경우에 get 방식의 id=value&id2=value2 같은 방식으로 처리된다. (텍스트로)
그래서 JSON 으로 변환된 문자열을 전송할 경우에 & 문자가 있으면 의도하지 않은 에러가 발생한다.
그래서 serialize 된 문자열에서
string postData = string.Format("shot={0}", JsonConvert.SerializeObject(shot)); postData = postData.Replace("&", "%26"); //string postData = string.Format("shot=TTT", JsonConvert.SerializeObject(shot)); query_string = "exec=updateshot"; var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://shots.php?" + query_string); httpWebRequest.ContentType = "text/json"; byte[] sendData = UTF8Encoding.UTF8.GetBytes(postData); httpWebRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8"; httpWebRequest.Method = "POST"; httpWebRequest.ContentLength = sendData.Length; Stream requestStream = httpWebRequest.GetRequestStream(); requestStream.Write(sendData, 0, sendData.Length); requestStream.Close(); HttpWebResponse httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse(); StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("UTF-8")); // Encoding.GetEncoding("EUC-KR") string shot_id = streamReader.ReadToEnd(); streamReader.Close(); httpWebResponse.Close(); postData = postData.Replace("&", "%26");
처럼 처리해주면 에러를 피할 수 있다.
'OLD POSTS' 카테고리의 다른 글
Setting Up Configuration Files for a New Game Project (0) | 2012.11.27 |
---|---|
PHP에서 json post 를 처리하는 방법. (0) | 2012.04.26 |
Fonts for ipad, iphone (0) | 2011.02.04 |
WPF의 datagrid 의 스타일 정의. (0) | 2011.01.07 |
PHP 에서 UTF-8 관련 문제. (0) | 2011.01.04 |
Fonts for ipad, iphone
http://www.michaelcritz.com/2010/04/02/fonts-for-ipad-iphone/
'OLD POSTS' 카테고리의 다른 글
PHP에서 json post 를 처리하는 방법. (0) | 2012.04.26 |
---|---|
[C#] HttpWebRequest 클래스를 이용한 POST 전송하기. (0) | 2012.04.26 |
WPF의 datagrid 의 스타일 정의. (0) | 2011.01.07 |
PHP 에서 UTF-8 관련 문제. (0) | 2011.01.04 |
Stencil Routed K-Buffer (0) | 2010.12.29 |
WPF의 datagrid 의 스타일 정의.
'OLD POSTS' 카테고리의 다른 글
[C#] HttpWebRequest 클래스를 이용한 POST 전송하기. (0) | 2012.04.26 |
---|---|
Fonts for ipad, iphone (0) | 2011.02.04 |
PHP 에서 UTF-8 관련 문제. (0) | 2011.01.04 |
Stencil Routed K-Buffer (0) | 2010.12.29 |
Tile Map Editor (0) | 2010.12.26 |
PHP 에서 UTF-8 관련 문제.
'OLD POSTS' 카테고리의 다른 글
Fonts for ipad, iphone (0) | 2011.02.04 |
---|---|
WPF의 datagrid 의 스타일 정의. (0) | 2011.01.07 |
Stencil Routed K-Buffer (0) | 2010.12.29 |
Tile Map Editor (0) | 2010.12.26 |
OpentTK/WPF integration (0) | 2010.12.22 |
Stencil Routed K-Buffer
'OLD POSTS' 카테고리의 다른 글
WPF의 datagrid 의 스타일 정의. (0) | 2011.01.07 |
---|---|
PHP 에서 UTF-8 관련 문제. (0) | 2011.01.04 |
Tile Map Editor (0) | 2010.12.26 |
OpentTK/WPF integration (0) | 2010.12.22 |
ATI Rendermonkey (0) | 2010.12.20 |
Tile Map Editor
'OLD POSTS' 카테고리의 다른 글
PHP 에서 UTF-8 관련 문제. (0) | 2011.01.04 |
---|---|
Stencil Routed K-Buffer (0) | 2010.12.29 |
OpentTK/WPF integration (0) | 2010.12.22 |
ATI Rendermonkey (0) | 2010.12.20 |
FX Composer 2.5 Sample Projects (0) | 2010.12.20 |
OpentTK/WPF integration
'OLD POSTS' 카테고리의 다른 글
Stencil Routed K-Buffer (0) | 2010.12.29 |
---|---|
Tile Map Editor (0) | 2010.12.26 |
ATI Rendermonkey (0) | 2010.12.20 |
FX Composer 2.5 Sample Projects (0) | 2010.12.20 |
Integrating XNA 4.0 and WPF (0) | 2010.12.17 |