我有2个PHP脚本,发送一个xml文件并捕获它.我正在使用cURL,一切都很好.现在我尝试做同样的事情,但使用HTTP over SSL(HTTPS).我已经安装了一个带有XAMPP的本地服务器,我按照以下帖子设置了SSL:在本地xampp/apache服务器上设置SSL.
我试图像这样发送xml文件:
<?php
/*
* XML Sender/Client.
*/
// Get our XML. You can declare it here or even load a file.
$xml = file_get_contents("data.xml");
// We send XML via CURL using POST with a http header of text/xml.
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
//i use this line only for debugging through fiddler. Must delete after done with debugging.
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
// set URL and other appropriate …Run Code Online (Sandbox Code Playgroud) 我有一个.war文件需要部署在公共 IP 中才能工作。您知道我可以尝试部署的免费网络主机吗?我知道 Apache、PHP、MySQL 的数十种解决方案,但从未真正听说过 Tomcat。
有任何想法吗?
所以我正在解析一个xml文件,并在屏幕上显示我解析的日期.日期如下:2012年5月31日星期四20:43:54 GMT.如何将日期转换为此格式:dd/mm/yy?我不需要时间.
好吧它崩溃了.我试过了 :
NSString *date = [[stories objectAtIndex: storyIndex] objectForKey: @"date"];
//changing dates format
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss Z"];
NSDate *myDate = [dateFormatter dateFromString:date];
NSString *dateText = [[NSString alloc] initWithString:[dateFormatter stringFromDate:myDate]];
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在开发一个Android应用程序,当它启动时:
1)我向我的服务器发出HTTP请求以发送一个小的JSON文件.
2)打开webView以显示URL.
当服务器正常运行时,绝对没有问题,一切顺利.
但是,如果由于任何原因服务器关闭,HTTP请求字面上会挂起,我需要等到有一个HTTP timeOut,大约30秒,直到我实际看到带有URL加载的webView.
我读到我不应该在UI线程内部建立任何网络,我应该使用另一个线程.
在BlackBerry,我已经开发了应用程序,这很简单:
new Thread(){
public void run(){
HttpConnection hc =
(HttpConnection)Connector.open("http://www.stackoverflow.com");
}
}.start();
Run Code Online (Sandbox Code Playgroud)
我只是开始一个新的线程,在里面我发出请求和所有必要的网络.这样,即使我的服务器无法访问,也会立即加载webView,而不会让用户等待并感觉到应用程序实际上已挂起.
我怎样才能在Android中以最简单的方式做到这一点?
我有一些数据,需要用这种结构创建一个json文件:
{"eventData":{"eventDate":"Jun 13, 2012 12:00:00 AM","eventLocation":{"latitude":43.93838383,"longitude":-3.46},"text":"hjhj","imageData":"raw data","imageFormat":"JPEG","expirationTime":1339538400000},"type":"ELDIARIOMONTANES","title":"accIDENTE"}
Run Code Online (Sandbox Code Playgroud)
可以请有人给我一些代码如何将我的数据放在具有这种结构的json文件中,或者至少是一个关于如何构建json结构的示例?
编辑
好的,所以我写了一些代码:
NSString *jsonString = @"[{\"eventData\":{\"eventDate\":\"Jun 13, 2012 12:00:00 AM\",\"eventLocation\":{\"latitude\":43.93838383,\"longitude\":-3.46},\"text\":\"hjhj\",\"imageData\":\"raw data\",\"imageFormat\":\"JPEG\",\"expirationTime\":1339538400000},\"type\":\"ELDIARIOMONTANES\",\"title\":\"accIDENTE\"}]";
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *e;
NSMutableArray *jsonList = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&e];
NSLog(@"jsonList: %@", jsonList);
Run Code Online (Sandbox Code Playgroud)
jsonList现在是一个json文件??? 它的格式是否正确?因为当我打印它时输出是:
jsonList: (
{
eventData = {
eventDate = "Jun 13, 2012 12:00:00 AM";
eventLocation = {
latitude = "43.93838383";
longitude = "-3.46";
};
expirationTime = 1339538400000;
imageData = "raw data";
imageFormat = JPEG;
text = hjhj;
};
title = accIDENTE;
type = …Run Code Online (Sandbox Code Playgroud) 我有这种格式的日期:
2012-06-26 12:00:00 +0000
Run Code Online (Sandbox Code Playgroud)
我想要做的是以这种格式转换它们:
Jun 26, 2012 12:00:00 AM
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法可以在obj-c上执行此操作,或者我必须解析所有硬核,并为此创建自己的函数?如果是,任何想法如何看起来像,因为我是iOS新手.非常感谢您阅读我的帖子:D
我在我的计算机上使用本地服务器,我正在尝试制作2个PHP脚本来发送xml文件并接收它.
要发送xml文件,我使用以下代码:
<?php
/*
* XML Sender/Client.
*/
// Get our XML. You can declare it here or even load a file.
$file = 'http://localhost/iPM/books.xml';
if(!$xml_builder = simplexml_load_file($file))
exit('Failed to open '.$file);
// We send XML via CURL using POST with a http header of text/xml.
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://localhost/iPM/receiver.php");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_REFERER, 'http://localhost/iPM/receiver.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, …Run Code Online (Sandbox Code Playgroud) 我见过像一百万个不同的日志功能,如log.i,log.v,log.d.
我只想在我的代码中在日志上输出一个简单的字符串,以查看是否所有内容都可以正常进行调试.
干净的方法是什么?
我正在尝试从我的BlackBerry OS <7.X应用程序发送一个json字符串到我的服务器.我正在尝试使用HTTP Post请求.到目前为止我所做的是:
String httpURL = "http://ip_of_my_server/phpServer/receiver2.php/" + jsonString;
try {
HttpConnection httpConn;
httpConn = (HttpConnection) Connector.open(httpURL + getConnectionString());
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
DataOutputStream _outStream = new DataOutputStream(httpConn.openDataOutputStream());
byte[] request_body = httpURL.getBytes();
for (int i = 0; i < request_body.length; i++) {
_outStream.writeByte(request_body[i]);
}
DataInputStream _inputStream = new DataInputStream(httpConn.openInputStream());
StringBuffer _responseMessage = new StringBuffer();
int ch;
while ((ch = _inputStream.read()) != -1) {
_responseMessage.append((char) ch);
}
String res = (_responseMessage.toString());
String response = res.trim();
System.out.println("!!!!!!!!!!!!!! Response is: " + …Run Code Online (Sandbox Code Playgroud) 可能重复:
HTTP身份验证的类型以及如何设计安全数据库?
我有一个iphone应用程序,它与我的服务器交换XML数据.
用户第一次运行应用程序时,应用程序将连接到URL并请求用户ID.
我使用HTTP基本身份验证,但是通过一个简单的Web调试器(嗅探器),我能够看到发送/接收来自我的服务器的所有XML表单以及发出用户id的url.
那么我可以做些什么来隐藏所有这些数据而不是用调试器可见?有人建议使用https(http over ssl),但我看到数以百万计的网站/应用程序使用http来做这些事情.我错过了什么吗?我能做些什么才能拥有这种安全保障?
我想要的是避免有人制作脚本并用垃圾填充我的数据库,因为所有内容(URL,XML文件的形式)都是可见的.
我需要分发一个我认识的50人的iphone应用程序.我想要他们,只有他们才能使用它.是否可以在AppStore外部分发iphone应用程序?我知道我可以为越狱手机生成一个.ipa,但这些手机并没有越狱.这有解决方案吗?