使 用 restful 怎 样 以json方式 把 结果 返回 给 app

使 用 restful 怎 样 以json方式 把 结果 返回 给 app

2个回答

restful API就是http返回数据。同时指定返回信息header中为application/json格式。这样客户端就可以处理接收的json数据了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
来自restful web服务的JSON

<div class="post-text" itemprop="text"> <p>I created a restful web service in php using the slim framework. One of the functions returns a dynamically created multidimensional array and encodes it as a JSON array like this</p> <pre><code>[{ "hid":100001, "SubTable":"grpsubs", "StatTable":"grpstats", "uid":2, "Status":"G" }, { "hid":100002, "SubTable":"gtmsubs", "StatTable":"gtmstats", "uid":2, "Status":"R" }] </code></pre> <p>In my android app I use the loopj framework to get the restful output like this</p> <pre><code>AsyncHttpClient client = new AsyncHttpClient(); client.addHeader("Authorization", key); client.post("https://mythic-beanbag-106723.appspot.com/v1/mine", params, new AsyncHttpResponseHandler() { // When the response returned by REST has Http response code '200' @Override public void onSuccess(String response) { // Hide Progress Dialog hospDialog.hide(); Log.e("Response", response); try { JSONArray array = new JSONArray(response); Log.e("array", String.valueOf(array.length())); } catch (JSONException e) { // TODO Auto-generated catch block Toast.makeText(getApplicationContext(), "Error Occurred [Server's JSON response might be invalid]!", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } </code></pre> <p>Using the Advanced REST Client in chrome I can see the JSON however in my app when I try outputting the JSON in the console <code>Log.e("Response", response);</code> it shows up as an empty array <code>[]</code>. This code works for my Login function and in php if instead of using a dynamically created array I use a static array like <code>array("abc"=&gt;array("def"=&gt;"ghi"), "jkl"=&gt;array("mno"=&gt;"pqr"))</code> the above code does output the JSON array.</p> <p>UPDATE:</p> <p>params</p> <pre><code>RequestParams params = new RequestParams(); params.put("uid", prefs.getInt("uid", 0)); </code></pre> </div>

使用Restful请求JSON

<div class="post-text" itemprop="text"> <p>When I test the code below it only fails </p> <p>Any Ideas? The link works fine</p> <pre class="lang-js prettyprint-override"><code>$.ajax({ url: 'http://ulacit3352.cloudapp.net/Login/webresources/generic/search/gera', type: 'GET', datatype: 'json', success: function(data) { alert("works") }, error: function() { alert("it does not"); } }); </code></pre> <p><a href="https://i.stack.imgur.com/PnUlO.png" rel="nofollow noreferrer">I get this on Chrome:</a></p> </div>

将JSON对象解析为Restful Web服务

<div class="post-text" itemprop="text"> <p>I am developing an android registration system that communicates with a mysql database through JSON. The restful web service was written with PHP and Slim library. i have tested the web service using Advanced Rest Client App by parsing a json payload data into it and it works perfectly fine with the result shown below. At the moment i am trying to parse user data from the android app to the server and it shows this error <code>(Error parsing data org.json.JSONException: Value &lt;html&gt;&lt;head&gt;&lt;title&gt;Slim of type java.lang.String cannot be converted to JSONObject)</code>. I would someone to tell me what i am doing wrong coz i feel the error is from my <strong>JSONParser</strong> class and <strong>Userfunction</strong>. Thanks in advance.</p> <p>Here is my test result</p> <blockquote> <p>{"tag":"signup","success":1,"error":0,"uid":"547d92b0480711.90973742",<br> "result":{"firstname":"mish","lastname":"harry","email":"mishael19@gmail.com"}}</p> </blockquote> <p>Here is JSONParser</p> <pre><code>public class JSONParser2 { static InputStream is = null; static JSONObject jObj = null; static String json = ""; // constructor public JSONParser2() { } public JSONObject makeHttpRequest(String url, String method, List&lt;NameValuePair&gt; params){ try{ if(method.equals("POST")){ DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); }else if(method == "GET"){ DefaultHttpClient httpClient = new DefaultHttpClient(); String paramString = URLEncodedUtils.format(params, "utf-8"); url += "?" + paramString; HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try{ BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + " "); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj; } } </code></pre> <p>here is my Userfunction</p> <pre><code>public class UserFunctions { private JSONParser2 jsonParser2; private static String signupURL = "http://globalpadtutorials.globalpad.info/loginSignup/v1/signup"; private static String signup_tag = "signup"; private static String postMethod = "POST"; public UserFunctions(){ jsonParser2 = new JSONParser2(); } public JSONObject signupUser(String fname, String lname, String email, String pwd){ List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("tag", signup_tag)); params.add(new BasicNameValuePair("firstname", fname)); params.add(new BasicNameValuePair("lastname", lname)); params.add(new BasicNameValuePair("email", email)); params.add(new BasicNameValuePair("password", pwd)); JSONObject json = jsonParser2.makeHttpRequest(signupURL, postMethod, params); Log.e("JSON", json.toString()); return json; } } </code></pre> <p>Error stack</p> <pre><code>12-02 11:04:19.681: E/JSON Parser(10024): Error parsing data org.json.JSONException: Value &lt;html&gt; &lt;head&gt;&lt;title&gt;Slim of type java.lang.String cannot be converted to JSONObject </code></pre> <p>PHP code</p> <pre><code>function createUser(){ $request = \Slim\Slim::getInstance()-&gt;request(); $resp = \Slim\Slim::getInstance()-&gt;response(); $resp['Content-Type'] = 'application/json; charset=utf-8'; $body = $request-&gt;getBody(); $users = json_decode($body); $dbhandler = new DbHandler(); $tag = $users-&gt;tag; $fname = $users-&gt;firstname; $lname = $users-&gt;lastname; $email = $users-&gt;email; $pwd = $users-&gt;password; $response = array("tag" =&gt; $tag, "success" =&gt; 0, "error" =&gt; 0); if($tag == 'signup') { if ($dbhandler-&gt;userExisted($email)) { $response["error"] = 2; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { $result = $dbhandler-&gt;addUser($fname, $lname, $email, $pwd); if ($result != false) { $response["success"] = 1; var_dump($result); $response["uid"] = $result["user_id"]; $response["result"]["firstname"] = $result["firstname"]; $response["result"]["lastname"] = $result["lastname"]; $response["result"]["email"] = $result["email"]; echo json_encode($response); } else { $response["error"] = 1; $response["error_msg"] = "An error occured during sign up"; echo json_encode($response); } } } else{ $response["error"] = 1; $response["error_msg"] = "Invalid tag request: ".$tag; echo json_encode($response); } } </code></pre> <p>html error</p> <p>Slim Application Errorbody{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</p><h1>Slim Application Error</h1><p>The application could not run because of the following error:</p><h2>Details</h2><strong>Type:</strong> ErrorException<strong>Code:</strong> 8<strong>Message:</strong> Trying to get property of non-object<strong>File:</strong> /home/globa390/public_html/globalpadtutorials/loginSignup/v1/index.php<strong>Line:</strong> 63<h2>Trace</h2><pre>#0 /home/globa390/public_html/globalpadtutorials/loginSignup/v1/index.php(63): Slim\Slim::handleErrors(8, 'Trying to get p...', '/home/globa390/...', 63, Array) 12-02 11:55:50.366: E/JSON(27492): #1 [internal function]: createUser() 12-02 11:55:50.366: E/JSON(27492): #2 /home/globa390/public_html/globalpadtutorials/loginSignup/library/Slim/Route.php(462): call_user_func_array('createUser', Array) 12-02 11:55:50.366: E/JSON(27492): #3 /home/globa390/public_html/globalpadtutorials/loginSignup/library/Slim/Slim.php(1326): Slim\Route-&gt;dispatch() 12-02 11:55:50.366: E/JSON(27492): #4 /home/globa390/public_html/globalpadtutorials/loginSignup/library/Slim/Middleware/Flash.php(85): Slim\Slim-&gt;call() 12-02 11:55:50.366: E/JSON(27492): #5 /home/globa390/public_html/globalpadtutorials/loginSignup/library/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash-&gt;call() 12-02 11:55:50.366: E/JSON(27492): #6 /home/globa390/public_html/globalpadtutorials/loginSignup/library/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride-&gt;call() 12-02 11:55:50.366: E/JSON(27492): #7 /home/globa390/public_html/globalpadtutorials/loginSignup/library/Slim/Slim.php(1271): Slim\Middleware\PrettyExceptions-&gt;call() 12-02 11:55:50.366: E/JSON(27492): #8 /home/globa390/public_html/globalpadtutorials/loginSignup/v1/index.php(12): Slim\Slim-&gt;run() 12-02 11:55:50.366: E/JSON(27492): #9 {main}</pre> </div>

WordPress REST API和WP JSON API有什么不同?

<div class="post-text" itemprop="text"> <p>I'm trying to code the user authentication feature for my app using API. I'm confused between <a href="https://developer.wordpress.org/rest-api/" rel="nofollow noreferrer">WordPress REST API</a> and <a href="https://wordpress.org/plugins/json-api/" rel="nofollow noreferrer">WordPress JSON API</a>? Based on the <a href="https://stackoverflow.com/questions/13679001/register-login-user-with-wordpress-json-api">Q&amp;A here</a>, it says I need WordPress JSON API. If my WP already has REST API, do I still need this JSON API?</p> </div>

请教个问题,restful接口同时提供给PC、移动端去调用,你们是如何区分出来的

请教个问题,restful接口同时提供给PC、移动端去调用,你们是如何区分出来的, 如PC传的是json串、内容不加密、移动端需要加密

使用http post如何传递多参数到restful web服务?

我创建了俩个数组参数和Objects数组,我想传递它们,我可以用下面的方法吗? @POST @Path("Test3") @Produces("text/plain") @Consumes({"application/json"}) public String Test3(String[] id1,String[] id2 ,Object [] oo) { String result = "Hello "; .... .... return result; } 我要传递到这个方法里相应的 json 是什么? 我使用了很多的jsons,总是获得下面的错误: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GlassFish Server Open Source Edition 4.0 - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Internal Server Error</h1><hr/><p><b>type</b> Exception report</p><p><b>message</b>Internal Server Error</p><p><b>description</b>The server encountered an internal error that prevented it from fulfilling this request.</p><p><b>exception</b> <pre>javax.servlet.ServletException: Servlet.init&#40;&#41; for servlet entities.service.ApplicationConfig threw exception</pre></p><p><b>root cause</b> <pre>org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization. [[FATAL] Method public java.lang.String entities.service.ItemFacadeREST.Test3&#40;java.lang.String,java.lang.String&#41; on resource class entities.service.ItemFacadeREST contains multiple parameters with no annotation. Unable to resolve the injection source.&#59; source=&#39;ResourceMethod{httpMethod=POST, consumedTypes=[application/json], producedTypes=[text/plain], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=MethodHandler{handlerClass=class entities.service.ItemFacadeREST, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@cdf30b]}, handlingMethod=public java.lang.String entities.service.ItemFacadeREST.Test3&#40;java.lang.String,java.lang.String&#41;, parameters=[Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}&#39;]</pre></p><p><b>note</b> <u>The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.</u></p><hr/><h3>GlassFish Server Open Source Edition 4.0 </h3></body></html> 对于http post我想从android中调用。

如何在Golang中将[] byte XML转换为JSON输出

<div class="post-text" itemprop="text"> <p>Is there a way to convert XML ([]byte) to JSON output in Golang?</p> <p>I've got below function where <code>body</code> is <code>[]byte</code> but I want to transform this XML response to JSON after some manipulation. I've tried <code>Unmarshal</code> in <code>xml</code> package with no success:</p> <pre><code>// POST func (u *UserResource) authenticateUser(request *restful.Request, response *restful.Response) { App := new(Api) App.url = "http://api.com/api" usr := new(User) err := request.ReadEntity(usr) if err != nil { response.AddHeader("Content-Type", "application/json") response.WriteErrorString(http.StatusInternalServerError, err.Error()) return } buf := []byte("&lt;app version=\"1.0\"&gt;&lt;request&gt;1111&lt;/request&gt;&lt;/app&gt;") r, err := http.Post(App.url, "text/plain", bytes.NewBuffer(buf)) if err != nil { response.AddHeader("Content-Type", "application/json") response.WriteErrorString(http.StatusInternalServerError, err.Error()) return } defer r.Body.Close() body, err := ioutil.ReadAll(r.Body) response.AddHeader("Content-Type", "application/json") response.WriteHeader(http.StatusCreated) // err = xml.Unmarshal(body, &amp;usr) // if err != nil { // fmt.Printf("error: %v", err) // return // } response.Write(body) // fmt.Print(&amp;usr.userName) } </code></pre> <p>I'm also using Go-restful package</p> </div>

使用Android的RESTful服务

<div class="post-text" itemprop="text"> <p>I can't seem to get a grasp on getting the web-to-android concept. I was reading a bunch of stuff about RESTful services and JSON, but I never found anything that could help me. My idea is to have Access database somewhere online, and get files from it on the android app.</p> <p>Where should I even begin? Say I got the DB and i got the server to put it on. Where does JSON come in play? Where are queries put into, some PHP, JSON, app itself?</p> <p>As far as I could understand from all I have read, the connection should be somehow like this</p> <p>WEB -- Database -- REST -- App</p> <p>How does it connect to PHP, where does the PHP file go? I have seen many topics here talking about it, but everyone has already made SOME progress, I don't know where to even start. Could you direct me to some book worth reading? </p> <p>Thank you</p> </div>

用restful写微信支付,统一下单成功,返回的支付信息正确,前端支付成功,回调接口显示签名失败。

下面是统一下单设置参数的代码 ``` public WxPayUnifiedOrderResult createOrder(YsUser ysUser, YsOrder order, String attach, HttpServletRequest request) throws WxPayException { LocalDateTime now = LocalDateTime.now(); WxPayUnifiedOrderRequest payRequest = new WxPayUnifiedOrderRequest(); payRequest.setDeviceInfo("WEB"); payRequest.setBody("壹送便利店微信商城订单"); payRequest.setOutTradeNo(order.getOrderId()); payRequest.setTotalFee(BaseWxPayRequest.yuanToFen("" + order.getPayPrice())); payRequest.setAttach(attach); payRequest.setSpbillCreateIp(IPUtils.getIpAddress(request)); payRequest.setTimeStart("" + now.getYear() + String.format("%02d", now.getMonth().getValue()) + String.format("%02d",now.getDayOfMonth()) + String.format("%02d", now.getHour()) + String.format("%02d", now.getMinute()) + String.format("%02d", now.getSecond())); LocalDateTime expireTime = now.plusMinutes(10); payRequest.setTimeExpire("" + expireTime.getYear() + String.format("%02d", expireTime.getMonth().getValue()) + String.format("%02d",expireTime.getDayOfMonth()) + String.format("%02d", expireTime.getHour()) + String.format("%02d", expireTime.getMinute()) + String.format("%02d", expireTime.getSecond())); payRequest.setNotifyUrl("http://" + Constants.DOMAIN + "/payments/weixin/notify/"); payRequest.setTradeType(WxPayConstants.TradeType.JSAPI); payRequest.setOpenid(ysUser.getOpenid()); return wxPayService.unifiedOrder(payRequest); } ``` 下面是回调接口的代码 ``` @PostMapping("/weixin/notify") public WxPayNotifyResponse wepayNotify(@RequestBody String xmlData) throws WxPayException { this.logger.info("开始回调了嘛"); WxPayOrderNotifyResult payResult = wxPayService.parseOrderNotifyResult(xmlData); if (payResult != null && !StringUtils.isEmpty(payResult.getOutTradeNo())) { //订单状态确认 this.logger.info("开始处理结果了嘛"); WxPayOrderQueryResult confirmResult = wxPayService.queryOrder(null, payResult.getOutTradeNo()); if (!StringUtils.isEmpty(confirmResult.getOutTradeNo()) && confirmResult.getOutTradeNo().equals(payResult.getOutTradeNo())) { YsOrder order = orderService.findByOrderId(payResult.getOutTradeNo()); this.logger.info("找到订单了嘛"); order.setPayType(Constants.ONLINE_PAY); order.setPayStatus(Constants.PAY_ORDER); order.setPayTime(new Date()); orderService.pay(order); ylyService.print(order); } } WxPayNotifyResponse response = new WxPayNotifyResponse(); response.setReturnCode(Constants.WEPAY_NOTIFY_SUCCESS); return response; } ``` 下面是后台日志输出的回调结果 ![图片说明](https://img-ask.csdn.net/upload/201807/21/1532163842_614905.png)

nodejs后台restful api上传图片的content-type问题

请问content-type=image/jpeg和multipart/form-data有什么关系? 我有一个nodejs的后台,是个restful api,我想开发个上传文件功能,请问合格content-type应该如何获取?

ajax phonegap 和 RESTful Codeigniter 问题

大家好 我现在准备用phonegap做一个安卓的app 现在需要做一个登录界面 有用户名密码 和提交按钮 当点击提交按钮 用ajax发送数据给 后台服务器 然后服务器返回true或者是false 如果是true跳入另外一个界面 如果是 false 弹出对话框提醒 现在问题是点击提交的时候一直显示ajax的error里面的 failed login。我觉得应该是url的问题 可是找了很久也不知道如何改: ajax代码: < script type="text/javascript"> $(document).ready(function() { $('#submit').click(function() { //Get data-theme data from all fields var username = $('#username').val(); var password = $('#password').val(); //Username and password can not be empty if(username =='') { alert('Please enter your username!'); return false; } if(password =='') { alert('Please enter your password!'); return false; } var form_data = { 'username': username, 'password': password }; //ajax code start here $.ajax ({ url: 'http://localhost/restserver/index.php/api/apiauth/auth', <!--//for test need to consolehange IP address here--> data: form_data, type: 'POST', cache: false, dataType: "json", error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Failed to login'); console.log(JSON.stringify(XMLHttpRequest)); console.log(JSON.stringify(textStatus)); console.log(JSON.stringify(errorThrown)); }, success: function (data) { alert("Success login"); //$.mobile.changePage("index.html", "slideup"); } }); return false; }); }); </script> html部分: <div> <label for="username">Username</label> <input name="username" type="text" id="username" placeholder="Username"/> </div> <div> <label for="password">password</label> <input name="password" type="password" id="password" placeholder="Password"/> </div> <fieldset> <div><button name="submit" type="button" data-theme="b" id="submit">Login</button> </div> </fieldset> </div> 后台RESTful CI: <?php defined('BASEPATH') OR exit('No direct script access allowed'); require APPPATH.'/libraries/REST_Controller.php'; class Apiauth extends REST_Controller { function auth_get() { $this->load->model('membership_model'); $query=$this->membership_model->validate(); $this->response($query,200); } } <?php class Membership_model extends CI_Model { function validate() { $this->db->where('username',$this->input->post('username')); $this->db->where('password',$this->input->post('username')); $query=$this->db->get('membership'); if($query->num_rows=1) { return true; } else { return false; } } }

PHP RESTful API访问Jersey客户端POST数据

<div class="post-text" itemprop="text"> <p>I am using a PHP RESTful API which is consumed by a Java desktop application using jersey 2.21. </p> <p>Usually, when I send a POST request from AngularJS, I can access the data via: </p> <pre><code>$data = json_decode(file_get_contents("php://input")); </code></pre> <p>However, when I use jersey, the data is put in the <code>$_POST</code> array. Here is my Jersey code: </p> <pre><code>final HashMap&lt;String, String&gt; params = // some hashmap with a few entries ClientConfig config = new ClientConfig(); Client client = ClientBuilder.newClient(config); MultivaluedMap formData = new MultivaluedHashMap(params); WebTarget target = client.target(url); // Get JSON String jsonResponse = target.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class); return jsonResponse; </code></pre> <p>How do I post the data from Jersey so that I can access it via the above PHP call?</p> <p>I know I can just use the <code>$_POST</code> array, but I need this API to be consumed from a mobile app, Java desktop &amp; an AngularJS app.</p> <p>Thanks in advance</p> </div>

Javascript / jquery 通过 POST 和 JSON 数据下载文件

<div class="post-text" itemprop="text"> <p>I have a jquery-based single-page webapp. It communicates with a RESTful web service via AJAX calls. </p> <p>I'm trying to accomplish the following:</p> <ol> <li>Submit a POST that contains JSON data to a REST url.</li> <li>If the request specifies a JSON response, then JSON is returned.</li> <li>If the request specifies a PDF/XLS/etc response, then a downloadable binary is returned.</li> </ol> <p>I have 1 &amp; 2 working now, and the client jquery app displays the returned data in the web page by creating DOM elements based on the JSON data. I also have #3 working from the web-service point of view, meaning it will create and return a binary file if given the correct JSON parameters. But I'm unsure the best way to deal with #3 in the client javascript code.</p> <p>Is it possible to get a downloadable file back from an ajax call like this? How do I get the browser to download and save the file?</p> <pre><code>$.ajax({ type: "POST", url: "/services/test", contentType: "application/json", data: JSON.stringify({category: 42, sort: 3, type: "pdf"}), dataType: "json", success: function(json, status){ if (status != "success") { log("Error loading data"); return; } log("Data loaded!"); }, error: function(result, status, err) { log("Error loading data"); return; } }); </code></pre> <p>The server responds with the following headers:</p> <pre><code>Content-Disposition:attachment; filename=export-1282022272283.pdf Content-Length:5120 Content-Type:application/pdf Server:Jetty(6.1.11) </code></pre> <p>Another idea is to generate the PDF and store it on the server and return JSON that includes a URL to the file. Then, issue another call in the ajax success handler to do something like the following:</p> <pre><code>success: function(json,status) { window.location.href = json.url; } </code></pre> <p>But doing that means I would need to make more than one call to the server, and my server would need to build downloadable files, store them somewhere, then periodically clean up that storage area.</p> <p>There must be a simpler way to accomplish this. Ideas?</p> <hr> <p>EDIT: After reviewing the docs for $.ajax, I see that the response dataType can only be one of <code>xml, html, script, json, jsonp, text</code>, so I'm guessing there is no way to directly download a file using an ajax request, unless I embed the binary file in using Data URI scheme as suggested in the @VinayC answer (which is not something I want to do).</p> <p>So I guess my options are:</p> <ol> <li><p>Not use ajax and instead submit a form post and embed my JSON data into the form values. Would probably need to mess with hidden iframes and such.</p></li> <li><p>Not use ajax and instead convert my JSON data into a query string to build a standard GET request and set window.location.href to this URL. May need to use event.preventDefault() in my click handler to keep browser from changing from the application URL.</p></li> <li><p>Use my other idea above, but enhanced with suggestions from the @naikus answer. Submit AJAX request with some parameter that lets web-service know this is being called via an ajax call. If the web service is called from an ajax call, simply return JSON with a URL to the generated resource. If the resource is called directly, then return the actual binary file.</p></li> </ol> <p>The more I think about it, the more I like the last option. This way I can get information back about the request (time to generate, size of file, error messages, etc.) and I can act on that information before starting the download. The downside is extra file management on the server.</p> <p>Any other ways to accomplish this? Any pros/cons to these methods I should be aware of?</p> </div> <p>转载于:https://stackoverflow.com/questions/3499597/javascript-jquery-to-download-file-via-post-with-json-data</p>

restful请求index方法时,真正请求的是index_get的方法,请教下源代码这块逻辑在哪。

请求的域名是:cidemo.com/Admin/RestfulController/index/2 但是走的是 Admin模块下的RestfulController控制器中的index_get 得方法 RestfulController控制器中我继承了REST_Controller 但是在REST_Controller 中我没发现将index 变成 index_get的逻辑啊。有哪位大神帮忙解答下 处理逻辑的控制器文件: ``` <?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * Example * * This is an example of a few basic user interaction methods you could use * all done with a hardcoded array. * */ // This can be removed if you use __autoload() in config.php OR use Modular Extensions require APPPATH . '/libraries/REST_Controller.php'; class Restful extends REST_Controller { function index_get($id = '') { var_dump($id);die; // Example data for testing. $widgets = array( 1 => array('id' => 1, 'name' => 'sprocket'), 2 => array('id' => 2, 'name' => 'gear') ); if (!$id) { $id = $this->get('id'); } if (!$id) { //$widgets = $this->widgets_model->getWidgets(); if ($widgets) $this->response($widgets, 200); // 200 being the HTTP response code else $this->response(array('error' => 'Couldn\'t find any widgets!'), 404); } //$widget = $this->widgets_model->getWidget($id); $widget = @$widgets[$id]; // test code if ($widget) $this->response($widget, 200); // 200 being the HTTP response code else $this->response(array('error' => 'Widget could not be found'), 404); } function index_post() { $data = $this->_post_args; try { //$id = $this->widgets_model->createWidget($data); $id = 3; // test code //throw new Exception('Invalid request data', 400); // test code //throw new Exception('Widget already exists', 409); // test code } catch (Exception $e) { // Here the model can throw exceptions like the following: // * For invalid input data: new Exception('Invalid request data', 400) // * For a conflict when attempting to create, like a resubmit: new Exception('Widget already exists', 409) $this->response(array('error' => $e->getMessage()), $e->getCode()); } if ($id) { $widget = array('id' => $id, 'name' => $data['name']); // test code //$widget = $this->widgets_model->getWidget($id); $this->response($widget, 201); // 201 being the HTTP response code } else $this->response(array('error' => 'Widget could not be created'), 404); } public function index_put() { $data = $this->_put_args; try { //$id = $this->widgets_model->updateWidget($data); $id = $data['id']; // test code //throw new Exception('Invalid request data', 400); // test code } catch (Exception $e) { // Here the model can throw exceptions like the following: // * For invalid input data: new Exception('Invalid request data', 400) // * For a conflict when attempting to create, like a resubmit: new Exception('Widget already exists', 409) $this->response(array('error' => $e->getMessage()), $e->getCode()); } if ($id) { $widget = array('id' => $data['id'], 'name' => $data['name']); // test code //$widget = $this->widgets_model->getWidget($id); $this->response($widget, 200); // 200 being the HTTP response code } else $this->response(array('error' => 'Widget could not be found'), 404); } function index_delete($id = '') { // Example data for testing. $widgets = array( 1 => array('id' => 1, 'name' => 'sprocket'), 2 => array('id' => 2, 'name' => 'gear'), 3 => array('id' => 3, 'name' => 'nut') ); if (!$id) { $id = $this->get('id'); } if (!$id) { $this->response(array('error' => 'An ID must be supplied to delete a widget'), 400); } //$widget = $this->widgets_model->getWidget($id); $widget = @$widgets[$id]; // test code if ($widget) { try { //$this->widgets_model->deleteWidget($id); //throw new Exception('Forbidden', 403); // test code } catch (Exception $e) { // Here the model can throw exceptions like the following: // * Client is not authorized: new Exception('Forbidden', 403) $this->response(array('error' => $e->getMessage()), $e->getCode()); } $this->response($widget, 200); // 200 being the HTTP response code } else $this->response(array('error' => 'Widget could not be found'), 404); } public function response($info) { if (is_array($info)) { echo json_encode($info); } } public function index(){ echo "this is index methods"; } } ``` 继承的restful类文件: ``` <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class REST_Controller extends CI_Controller { private $method; private $format; private $get_args; private $put_args; private $args; // List all supported methods, the first will be the default format private $supported_formats = array( 'xml' => 'application/xml', 'json' => 'application/json', 'serialize' => 'text/plain', 'php' => 'text/plain', 'html' => 'text/html', 'csv' => 'application/csv' ); // Constructor function function __construct() { parent::__construct(); // How is this request being made? POST, DELETE, GET, PUT? $this->method = $this->_detect_method(); // Lets grab the config and get ready to party $this->load->config('rest'); if($this->config->item('rest_auth') == 'basic') { echo "basic"; $this->_prepareBasicAuth(); } elseif($this->config->item('rest_auth') == 'digest') { echo "digest"; $this->_prepareDigestAuth(); } // Set up our GET variables $this->get_args = $this->uri->uri_to_assoc();//获取参数 var_dump($this->get_args); // Set up out PUT variables var_dump(parse_str(file_get_contents('php://input'), $this->put_args)); parse_str(file_get_contents('php://input'), $this->put_args); // Merge both for one mega-args variable $this->args = array_merge($this->get_args, $this->put_args); // Which format should the data be returned in? $this->format = $this->_detect_format();//设置参数方式 json 、 xml } /* * Remap * * Requests are not made to methods directly The request will be for an "object". * this simply maps the object and method to the correct Controller method. */ function _remap($object_called) { $controller_method = $object_called.'_'.$this->method; if(method_exists($this, $controller_method)) { $this->$controller_method(); } else { show_404(); } } /* * Responce * * Takes pure data and optionally a status code, then creates the responce */ function responce($data = '', $http_code = 200) { $this->output->set_status_header($http_code); // If the method exists, call it if(method_exists($this, '_'.$this->format)) { // Set a XML header $this->output->set_header('Content-type: '.$this->supported_formats[$this->format]); $formatted_data = $this->{'_'.$this->format}($data); $this->output->set_output( $formatted_data ); } else { $this->output->set_output( $data ); } } /* * Detect format * * Detect which format should be used to output the data */ private function _detect_format() { if(array_key_exists('format', $this->args) && array_key_exists($this->args['format'], $this->supported_formats)) { return $this->args['format']; } // If a HTTP_ACCEPT header is present... if($this->input->server('HTTP_ACCEPT')) { // Check to see if it matches a supported format foreach(array_keys($this->supported_formats) as $format) { if(strpos($this->input->server('HTTP_ACCEPT'), $format) !== FALSE) { return $format; } } } // If it doesnt match any or no HTTP_ACCEPT header exists, uses the first (default) supported format list($default)=array_keys($this->supported_formats); return $default; } /* * Detect method * * Detect which method (POST, PUT, GET, DELETE) is being used */ private function _detect_method() { $method = strtolower($this->input->server('REQUEST_METHOD')); if(in_array($method, array('get', 'delete', 'post', 'put'))) { return $method; } return 'get'; } // INPUT FUNCTION -------------------------------------------------------------- public function get($key) { return array_key_exists($key, $this->get_args) ? $this->input->xss_clean( $this->get_args[$key] ) : $this->input->get($key) ; } public function post($key) { return $this->input->post($key); } public function put($key) { return array_key_exists($key, $this->put_args) ? $this->input->xss_clean( $this->put_args[$key] ) : FALSE ; } // SECURITY FUNCTIONS --------------------------------------------------------- private function _checkLogin($username = '', $password = NULL) { if(empty($username)) { return FALSE; } $valid_logins =& $this->config->item('rest_valid_logins'); if(!array_key_exists($username, $valid_logins)) { return FALSE; } // If actually NULL (not empty string) then do not check it if($password !== NULL) { if($valid_logins[$username] != $password) { return FALSE; } } return TRUE; } private function _prepareBasicAuth() { $username = NULL; $password = NULL; // mod_php if (isset($_SERVER['PHP_AUTH_USER'])) { $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; } // most other servers elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) { if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']),'basic')===0) { list($username,$password) = explode(':',base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); } } if ( !$this->_checkLogin($username, $password) ) { $this->_forceLogin(); } } private function _prepareDigestAuth() { $uniqid = uniqid(""); // Empty argument for backward compatibility // We need to test which server authentication variable to use // because the PHP ISAPI module in IIS acts different from CGI if(isset($_SERVER['PHP_AUTH_DIGEST'])) { $digest_string = $_SERVER['PHP_AUTH_DIGEST']; } elseif(isset($_SERVER['HTTP_AUTHORIZATION'])) { $digest_string = $_SERVER['HTTP_AUTHORIZATION']; } else { $digest_string = ""; } /* The $_SESSION['error_prompted'] variabile is used to ask the password again if none given or if the user enters a wrong auth. informations. */ if ( empty($digest_string) ) { $this->_forceLogin($uniqid); exit; } // We need to retrieve authentication informations from the $auth_data variable preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches); $digest = array_combine($matches[1], $matches[2]); if ( !array_key_exists('username', $digest) || !$this->_checkLogin($digest['username']) ) { $this->responce(NULL, 401); exit; } $valid_logins =& $this->config->item('rest_valid_logins'); $valid_pass = $valid_logins[$digest['username']]; // This is the valid response expected $A1 = md5($digest['username'] . ':' . $this->config->item('rest_realm') . ':' . $valid_pass); $A2 = md5(strtoupper($this->method).':'.$digest['uri']); $valid_response = md5($A1.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$A2); if ($digest['response'] != $valid_response) { $this->responce(NULL, 401); exit; } } private function _forceLogin($nonce = '') { header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.1 401 Unauthorized'); if($this->config->item('rest_auth') == 'basic') { header('WWW-Authenticate: Basic realm="'.$this->config->item('rest_realm').'"'); } elseif($this->config->item('rest_auth') == 'digest') { header('WWW-Authenticate: Digest realm="'.$this->config->item('rest_realm'). '" qop="auth" nonce="'.$nonce.'" opaque="'.md5($this->config->item('rest_realm')).'"'); } echo 'Text to send if user hits Cancel button'; die(); } // FORMATING FUNCTIONS --------------------------------------------------------- // Format XML for output private function _xml($data = array(), $structure = NULL, $basenode = 'xml') { // turn off compatibility mode as simple xml throws a wobbly if you don't. if (ini_get('zend.ze1_compatibility_mode') == 1) { ini_set ('zend.ze1_compatibility_mode', 0); } if ($structure == NULL) { $structure = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$basenode />"); } // loop through the data passed in. foreach($data as $key => $value) { // no numeric keys in our xml please! if (is_numeric($key)) { // make string key... //$key = "item_". (string) $key; $key = "item"; } // replace anything not alpha numeric $key = preg_replace('/[^a-z0-9_-]/i', '', $key); // if there is another array found recrusively call this function if (is_array($value)) { $node = $structure->addChild($key); // recrusive call. $this->_xml($value, $node, $basenode); } else { // add single node. $value = htmlentities($value, ENT_NOQUOTES, "UTF-8"); $UsedKeys[] = $key; $structure->addChild($key, $value); } } // pass back as string. or simple xml object if you want! return $structure->asXML(); } // Format HTML for output private function _html($data = array()) { // Multi-dimentional array if(isset($data[0])) { $headings = array_keys($data[0]); } // Single array else { $headings = array_keys($data); } $this->load->library('table'); $this->table->set_heading($headings); foreach($data as &$row) { $this->table->add_row($row); } return $this->table->generate(); } // Format HTML for output private function _csv($data = array()) { // Multi-dimentional array if(isset($data[0])) { $headings = array_keys($data[0]); $output = implode(',', $headings)."\r\n"; foreach($data as &$row) { $output .= '"'.implode('","',$row)."\"\r\n"; } } // Single array else { $headings = array_keys($data); $output = implode(',', $headings)."\r\n"; $output .= '"'.implode('","',$data)."\"\r\n"; } return $output; } // Encode as JSON private function _json($data = array()) { return json_encode($data); } // Encode as Serialized array private function _serialize($data = array()) { return serialize($data); } // Encode raw PHP private function _php($data = array()) { return var_export($data); } } ?> ```

状态404未找到:yii2 RESTful API PUT方法

<div class="post-text" itemprop="text"> <p>I'm following this link to build a set of RESTful APIs: <a href="http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html" rel="nofollow">http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html</a></p> <p>First, create a controller as follows,</p> <pre><code>class RestorderController extends AbstractRestController { public $modelClass = 'app\modules\duangorder\models\Order'; } </code></pre> <p>Then, modify the configuration about the urlManager component in my application configuration:</p> <pre><code>'urlManager' =&gt; [ 'class' =&gt; 'yii\web\UrlManager', 'enablePrettyUrl' =&gt; true, 'enableStrictParsing' =&gt; true, 'showScriptName' =&gt; false, 'rules' =&gt; [ ['class' =&gt; 'yii est\UrlRule', 'controller' =&gt; 'duangorder/restorder'], ], ], </code></pre> <p>Trying it Out</p> <p>GET <a href="http://e9049d9.tunnel.mobi/yii2-basic/web/index.php?r=duangorder/restorder&amp;token=gh_9831478f66cb" rel="nofollow">http://e9049d9.tunnel.mobi/yii2-basic/web/index.php?r=duangorder/restorder&amp;token=gh_9831478f66cb</a></p> <p>works fine, can get json output.</p> <p>But when I: PUT <a href="http://e9049d9.tunnel.mobi/yii2-basic/web/index.php?r=duangorder/restorder/1" rel="nofollow">http://e9049d9.tunnel.mobi/yii2-basic/web/index.php?r=duangorder/restorder/1</a> it's said Status 404 Not Found</p> <p>Where is the problem? Thanks...</p> <p><strong>updated</strong>:</p> <p>now I think should add update in url:</p> <pre><code>curl -l -H "Accept: application/json" -H '"processed":"0"' -X PUT -d '{"processed":"0"}' "http://e9049d9.tunnel.mobi/yii2-basic/web/index.php?r=duangorder/restorder/update&amp;id=1" {"id":1,"token":"gh_9831478f66cb","order_id":"143978240336383","openid":"oPuB9wkVKTXn9AZ9idM-XqhUvxh0","table_id":0,"ctime":1439782403,"phone":"13211675827","address":"address","remark":"quick","detail":"{\"4\":{\"num\":2,\"id\":\"4\",\"name\":\"\\u86cb\\u7092\\u996d\",\"price\":\"10.00\",\"total\":20},\"6\":{\"num\":1,\"id\":\"6\",\"name\":\"\\u626c\\u5dde\\u7092\\u996d\",\"price\":\"10.00\",\"total\":\"10.00\"},\"5\":{\"num\":1,\"id\":\"5\",\"name\":\"\\u51b0\\u6dc7\\u51cc\",\"price\":\"8.00\",\"total\":\"8.00\"}}","name":"tingjun","processed":"1","paid":"0"} </code></pre> <p>but processed's still not be updated... </p> </div>

android和RESTful Web服务实现

<div class="post-text" itemprop="text"> <p>I develop and a android app and associated web service. This web service will be accessed from my app only. It is not public. I have read the REST standard and understood various Http methods GET,POST,PUT...etc. For my app i use POST only</p> <p>In my php code i process request and send response messages. If someone asks whether it is as per REST standard or not?. I don't' know what to say. Is there any problem in my code. The attached is my php and android code. Here i am updating address of a person from mobile to the web server. Code work ok as of now.</p> <p>-- php</p> <pre><code>&lt;?php $username=$_POST["username"]; $gyshadd=$_POST["address"]; $gyshphone=$_POST["phone"]; $connect = mysql_connect("127.0.0.1","melon","my password") or die("jothi can't' connect"); mysql_select_db("taxidata") or die("no database"); if (!empty($_POST)) { //check username already exists $query = mysql_query("SELECT * FROM drivertable WHERE userid = '$username'"); $numrows = mysql_num_rows($query); if($numrows == 0 ) { $response["success"] = 0; $response["message"] = "username doesn't'exists"; die(json_encode($response)); } else { //create new account $query = mysql_query("UPDATE drivertable SET dadd='$gyshadd', mobile='$gyshphone' WHERE userid='$username'"); $response["success"] = 1; $response["message"] = "Address update success"; die(json_encode($response)); } } else { $response["success"] = 0; $response["message"] = " One or both of the fields are empty "; die(json_encode($response)); } mysql_close(); ?&gt; </code></pre> <hr> <p>android code executed from async task</p> <pre><code> private static final String ADDRESS_URL = "http://www.xyz123.com/test/updateaddress.php"; List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(3); params.add(new BasicNameValuePair("username", username)); params.add(new BasicNameValuePair("address", daddress)); params.add(new BasicNameValuePair("phone", phone)); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(ADDRESS_URL); httppost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse response = httpclient.execute(httppost); String json = EntityUtils.toString(response.getEntity()); JSONObject myObject = new JSONObject(json); </code></pre> <p>————————</p> </div>

CakePHP 2的Restful API

<div class="post-text" itemprop="text"> <p>I am creating a Restful WebService with CakePHP 2 however, i am getting 500 Internal Server Error since i am not able to capture Post Data. The Rest Server is as below:</p> <pre><code>App::import ( 'Vendor', 'ExchangeFunctions', array ('file'=&gt; 'exchange/exchangefunctions.php')); class ExchangeController extends AppController { public $components = array('RequestHandler'); public function index() { $exchange = new ExchangeFunctions(); $data = $this-&gt;request-&gt;data('json_decode'); $exchange-&gt;username = $_POST['username']; $exchange-&gt;password = $_POST['password']; $emailList = $exchange-&gt;listEmails(); $response = new stdClass(); $response-&gt;emailList = $emailList; foreach($emailList-&gt;messages as $listid =&gt; $email) { $tempEmail = $exchange-&gt;getEmailContent( $email-&gt;Id, $email-&gt;ChangeKey, TRUE, $_POST['attachmentPath'] ); $response-&gt;emails[$tempEmail['attachmentCode']] = $tempEmail; } $this-&gt;set('response', $response); $this-&gt;set('_serialize','response'); } } </code></pre> <p>and the client goes as:</p> <pre><code>class ApitestController extends AppController { Public function index() { $this-&gt;layout = 'ajax'; $jRequestURLPrefix = 'http://localhost/EWSApi/'; $postUrl = $jRequestURLPrefix."exchange/index.json"; $postData = array( 'username' =&gt; 'username', 'password' =&gt; 'password', 'attachmentPath'=&gt; $_SERVER['DOCUMENT_ROOT'] . $this-&gt;base . DIRECTORY_SEPARATOR . 'emailDownloads' . DIRECTORY_SEPARATOR . 'attachments' ); $postData = json_encode($postData); pr($postData); $ch = curl_init( $postUrl ); $options = array( CURLOPT_RETURNTRANSFER=&gt; true, CURLOPT_HTTPHEADER =&gt; array( 'Content-Type: application/json', 'Content-Length: ' . strlen($postData) ), CURLOPT_CUSTOMREQUEST =&gt; 'GET', CURLOPT_POSTFIELDS =&gt; $postData, ); curl_setopt_array( $ch, $options ); $jsonString = curl_exec($ch); curl_close($ch); $data = json_decode($jsonString, FALSE); echo $jsonString; } } </code></pre> <p>Not sure where i am messing up! Please help!</p> </div>

创建Restful API在响应之前应该放置哪种标头?

<div class="post-text" itemprop="text"> <p>I am not finding a whole lot of information on this, maybe I am just searching wrong, who knows.. What I want to know or try to figure out is what kind of headers should I output for API responses example</p> <pre><code>header('Content-Type: application/json'); </code></pre> <p>Is something I would put out for the type of data, but are there others for time, expiration, or anything else for that matter that I should concern myself with? </p> <p>Ultimately I am attempting to make an API for an app I want to develope so I am trying to figure out early what will be cross platform compliant and what needs are so I can try to build them into my idea of what would be part of standard dev</p> </div>

程序员的兼职技能课

获取讲师答疑方式: 在付费视频第一节(触摸命令_ALL)片头有二维码及加群流程介绍 限时福利 原价99元,今日仅需39元!购课添加小助手(微信号:csdn590)按提示还可领取价值800元的编程大礼包! 讲师介绍: 苏奕嘉&nbsp;前阿里UC项目工程师 脚本开发平台官方认证满级(六级)开发者。 我将如何教会你通过【定制脚本】赚到你人生的第一桶金? 零基础程序定制脚本开发课程,是完全针对零脚本开发经验的小白而设计,课程内容共分为3大阶段: ①前期将带你掌握Q开发语言和界面交互开发能力; ②中期通过实战来制作有具体需求的定制脚本; ③后期将解锁脚本的更高阶玩法,打通任督二脉; ④应用定制脚本合法赚取额外收入的完整经验分享,带你通过程序定制脚本开发这项副业,赚取到你的第一桶金!

Windows版YOLOv4目标检测实战:训练自己的数据集

课程演示环境:Windows10; cuda 10.2; cudnn7.6.5; Python3.7; VisualStudio2019; OpenCV3.4 需要学习ubuntu系统上YOLOv4的同学请前往:《YOLOv4目标检测实战:训练自己的数据集》 课程链接:https://edu.csdn.net/course/detail/28745 YOLOv4来了!速度和精度双提升! 与 YOLOv3 相比,新版本的 AP (精度)和 FPS (每秒帧率)分别提高了 10% 和 12%。 YOLO系列是基于深度学习的端到端实时目标检测方法。本课程将手把手地教大家使用labelImg标注和使用YOLOv4训练自己的数据集。课程实战分为两个项目:单目标检测(足球目标检测)和多目标检测(足球和梅西同时检测)。 本课程的YOLOv4使用AlexyAB/darknet,在Windows系统上做项目演示。包括:安装软件环境、安装YOLOv4、标注自己的数据集、整理自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计(mAP计算)和先验框聚类分析。还将介绍改善YOLOv4目标检测性能的技巧。 除本课程《Windows版YOLOv4目标检测实战:训练自己的数据集》外,本人将推出有关YOLOv4目标检测的系列课程。请持续关注该系列的其它视频课程,包括: 《Windows版YOLOv4目标检测实战:人脸口罩佩戴检测》 《Windows版YOLOv4目标检测实战:中国交通标志识别》 《Windows版YOLOv4目标检测:原理与源码解析》

lena全身原图(非256*256版本,而是全身原图)

lena全身原图(非256*256版本,而是全身原图) lena原图很有意思,我们通常所用的256*256图片是在lena原图上截取了头部部分的256*256正方形得到的. 原图是花花公子杂志上的一个

快速入门Android开发 视频 教程 android studio

这是一门快速入门Android开发课程,顾名思义是让大家能快速入门Android开发。 学完能让你学会如下知识点: Android的发展历程 搭建Java开发环境 搭建Android开发环境 Android Studio基础使用方法 Android Studio创建项目 项目运行到模拟器 项目运行到真实手机 Android中常用控件 排查开发中的错误 Android中请求网络 常用Android开发命令 快速入门Gradle构建系统 项目实战:看美图 常用Android Studio使用技巧 项目签名打包 如何上架市场

Java调用微信支付

Java 使用微信支付 一. 准备工作 1.

汽车租赁管理系统需求分析规格说明书

汽车租赁管理系统需求分析规格说明书,这只是一个模板,如果有不会的可以借鉴一下,还是蛮详细的。。。。

C/C++跨平台研发从基础到高阶实战系列套餐

一 专题从基础的C语言核心到c++ 和stl完成基础强化; 二 再到数据结构,设计模式完成专业计算机技能强化; 三 通过跨平台网络编程,linux编程,qt界面编程,mfc编程,windows编程,c++与lua联合编程来完成应用强化 四 最后通过基于ffmpeg的音视频播放器,直播推流,屏幕录像,

程序员的算法通关课:知己知彼(第一季)

【超实用课程内容】 程序员对于算法一直又爱又恨!特别是在求职面试时,算法类问题绝对是不可逃避的提问点!本门课程作为算法面试系列的第一季,会从“知己知彼”的角度,聊聊关于算法面试的那些事~ 【哪些人适合学习这门课程?】 求职中的开发者,对于面试算法阶段缺少经验 想了解实际工作中算法相关知识 在职程序员,算法基础薄弱,急需充电 【超人气讲师】 孙秀洋&nbsp;| 服务器端工程师 硕士毕业于哈工大计算机科学与技术专业,ACM亚洲区赛铜奖获得者,先后在腾讯和百度从事一线技术研发,对算法和后端技术有深刻见解。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27272 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程无限观看时长,但是大家可以抓紧时间学习后一起讨论哦~

机器学习初学者必会的案例精讲

通过六个实际的编码项目,带领同学入门人工智能。这些项目涉及机器学习(回归,分类,聚类),深度学习(神经网络),底层数学算法,Weka数据挖掘,利用Git开源项目实战等。

Python入门视频精讲

Python入门视频培训课程以通俗易懂的方式讲解Python核心技术,Python基础,Python入门。适合初学者的教程,让你少走弯路! 课程内容包括:1.Python简介和安装 、2.第一个Python程序、PyCharm的使用 、3.Python基础、4.函数、5.高级特性、6.面向对象、7.模块、8.异常处理和IO操作、9.访问数据库MySQL。教学全程采用笔记+代码案例的形式讲解,通俗易懂!!!

我以为我对Mysql事务很熟,直到我遇到了阿里面试官

太惨了,面试又被吊打

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

Java62数据提取代码

利用苹果手机微信下面的wx.data文件提取出62数据,通过62可以实现不同设备直接登陆,可以通过文件流的方式用脚本上传到服务器进行解析

Python代码实现飞机大战

文章目录经典飞机大战一.游戏设定二.我方飞机三.敌方飞机四.发射子弹五.发放补给包六.主模块 经典飞机大战 源代码以及素材资料(图片,音频)可从下面的github中下载: 飞机大战源代码以及素材资料github项目地址链接 ————————————————————————————————————————————————————————— 不知道大家有没有打过飞机,喜不喜欢打飞机。当我第一次接触这个东西的时候,我的内心是被震撼到的。第一次接触打飞机的时候作者本人是身心愉悦的,因为周边的朋友都在打飞机, 每

2018年全国大学生计算机技能应用大赛决赛 大题

2018年全国大学生计算机技能应用大赛决赛大题,程序填空和程序设计(侵删)

Lena图像处理测试专业用图,高清完整全身原图

Lena图像处理测试专业用图,高清完整全身原图,该图片很好的包含了平坦区域、阴影和纹理等细节,这些都有益于测试各种不同的图像处理算法。它是一幅很好的测试照片!其次,由于这是一个非常有魅力女人的照片。

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

verilog实现地铁系统售票

使用 verilog 实现地铁售票

Python+OpenCV计算机视觉

Python+OpenCV计算机视觉系统全面的介绍。

Python可以这样学(第四季:数据分析与科学计算可视化)

董付国老师系列教材《Python程序设计(第2版)》(ISBN:9787302436515)、《Python可以这样学》(ISBN:9787302456469)配套视频,在教材基础上又增加了大量内容,通过实例讲解numpy、scipy、pandas、statistics、matplotlib等标准库和扩展库用法。

150讲轻松搞定Python网络爬虫

【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑

获取Linux下Ftp目录树并逐步绑定到treeview

在linux下抓取目录树,双击后获取该节点子节点(逐步生成)。另外有两个类,一个是windows下的(一次性获取目录树),一个是linux下的(足部获取目录树)

YOLOv3目标检测实战系列课程

《YOLOv3目标检测实战系列课程》旨在帮助大家掌握YOLOv3目标检测的训练、原理、源码与网络模型改进方法。 本课程的YOLOv3使用原作darknet(c语言编写),在Ubuntu系统上做项目演示。 本系列课程包括三门课: (1)《YOLOv3目标检测实战:训练自己的数据集》 包括:安装darknet、给自己的数据集打标签、整理自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计(mAP计算和画出PR曲线)和先验框聚类。 (2)《YOLOv3目标检测:原理与源码解析》讲解YOLOv1、YOLOv2、YOLOv3的原理、程序流程并解析各层的源码。 (3)《YOLOv3目标检测:网络模型改进方法》讲解YOLOv3的改进方法,包括改进1:不显示指定类别目标的方法 (增加功能) ;改进2:合并BN层到卷积层 (加快推理速度) ; 改进3:使用GIoU指标和损失函数 (提高检测精度) ;改进4:tiny YOLOv3 (简化网络模型)并介绍 AlexeyAB/darknet项目。

手把手实现Java图书管理系统(附源码)

【超实用课程内容】 本课程演示的是一套基于Java的SSM框架实现的图书管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。详细介绍了图书管理系统的实现,包括:环境搭建、系统业务、技术实现、项目运行、功能演示、系统扩展等,以通俗易懂的方式,手把手的带你从零开始运行本套图书管理系统,该项目附带全部源码可作为毕设使用。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27513 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化

微信小程序开发实战之番茄时钟开发

微信小程序番茄时钟视频教程,本课程将带着各位学员开发一个小程序初级实战类项目,针对只看过官方文档而又无从下手的开发者来说,可以作为一个较好的练手项目,对于有小程序开发经验的开发者而言,可以更好加深对小程序各类组件和API 的理解,为更深层次高难度的项目做铺垫。

Java 最常见的 200+ 面试题:面试必备

这份面试清单是从我 2015 年做了 TeamLeader 之后开始收集的,一方面是给公司招聘用,另一方面是想用它来挖掘在 Java 技术栈中,还有那些知识点是我不知道的,我想找到这些技术盲点,然后修复它,以此来提高自己的技术水平。虽然我是从 2009 年就开始参加编程工作了,但我依旧觉得自己现在要学的东西很多,并且学习这些知识,让我很有成就感和满足感,那所以何乐而不为呢? 说回面试的事,这份面试...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

微信小程序 实例汇总 完整项目源代码

微信小程序 实例汇总 完整项目源代码

基于西门子S7—1200的单部六层电梯设计程序,1部6层电梯

基于西门子S7—1200的单部六层电梯设计程序,1部6层电梯。 本系统控制六层电梯, 采用集选控制方式。 为了完成设定的控制任务, 主要根据电梯输入/输出点数确定PLC 的机型。 根据电梯控制的要求,

Rabit兔子点云模型.zip

加载点云模型导入PCL点云库,有三种格式的点云兔子,压缩包总共有ply/pcd/xyz三种格式,可以结合我的博客内容练习怎么加载显示

相关热词 c#分级显示数据 c# 不区分大小写替换 c#中调用就java c#正则表达式 验证小数 c# vscode 配置 c#三维数组能存多少数据 c# 新建excel c#多个文本框 c#怎么创建tcp通讯 c# mvc 电子病例
立即提问
相关内容推荐