标签: http-post

将数据发送到WebView中加载的页面

我的应用程序中有一个WebView,我加载了http://mysite.com/somepage.php

我知道我可以使用GET方法传递数据,因为这恰好在URL字符串中.我想知道如何使用POST方法将数据传递到页面.我试过搜索,但找不到具体的东西.谢谢.

post android http-post webview

5
推荐指数
1
解决办法
7429
查看次数

将javascript对象序列化为json并返回

我正在使用jQuery post方法将一些数据发送到服务器.我不想自己构建JSON字符串,而只想使用Javascript对象.当我得到返回字符串(在JSON中)时,我想自动构造一个相应的javascript对象.这可能吗?

提前致谢.

javascript jquery json http-post

5
推荐指数
2
解决办法
3万
查看次数

如何以编程方式将POST请求发送到JSF页面而不使用HTML表单?

我有非常简单的JSF bean,如下所示:

import org.jboss.seam.annotations.Name;

@Name(Sample.NAME)
public class Sample {

    public static final String NAME="df";

    private String text = "text-test";

    public void sampleM(){
        System.out.println("Test: "+text);
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}
Run Code Online (Sandbox Code Playgroud)

和JSF表单连接这个组件:

<h:form id="sampleForm">
        <h:commandButton id="sampleButton" action="#{df.sampleM()}" value="ok" />
</h:form>
Run Code Online (Sandbox Code Playgroud)

现在,我想以编程方式将POST请求发送到此表单.

根据我的调查,这里的关键是POST参数.正确选择可以得到正确的结果(字符串'测试:文本测试'打印在serwer的控制台上).

所以问题是:我应该如何选择正确的POST数据?

上面显示的JSF表单生成此HTML表单:

<form id="sampleForm" name="sampleForm" method="post" action="/pages/main/main.smnet" enctype="application/x-www-form-urlencoded">
    <input type="hidden" name="sampleForm" value="sampleForm" />
    <input id="sampleForm:sampleButton" type="submit" name="sampleForm:sampleButton" value="ok" />
    <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id65" autocomplete="off" /> …
Run Code Online (Sandbox Code Playgroud)

jsf http-post jsf-2 http-request-parameters

5
推荐指数
1
解决办法
2万
查看次数

android如何发送int和double作为namevaluepair作为http post

我有一个应用程序,我试图使用http帖子将数据发送到Web服务.用户数据是字符串int和double的混合.在应用程序中,所有都表示为字符串,因为当我使用AsyncTask来运行网络调用时(因此它不在主线程上),params数组是String类型.

我遇到的问题是服务器有时需要一个int.例如,compID是服务器期望的int.使用http帖子时,我使用NameValuePair.这只会接受字符串.如何将int或double传递给http帖子?

在我的活动中.

String[] params = new String[]{tagCompany, tagId, tagPerson, OUT,
                                null, null,null, null, null, null}; 
                        AsyncPostData apd = new AsyncPostData();
                        apd.execute(params);





private class AsyncPostData extends AsyncTask<String, Void, Void> {

        ProgressDialog progressDialog;

        @Override
        protected void onPreExecute()
        {
            progressDialog= ProgressDialog.show(NfcscannerActivity.this, 
                    "Connecting to Server"," Posting data...", true);            
        };  


        @Override
        protected Void doInBackground(String... params) {

            nfcscannerapplication.loginWebservice.postData(params[0], params[1], params[2], params[3], params[4],
                    params[5], params[6], params[7], params[8], params[9]);
            return null;
        }

         @Override
            protected void onPostExecute(Void result)
            {
             super.onPostExecute(result);
                if(progressDialog != null)
                progressDialog.dismiss();

            }
    }//end of AsyncPostData …
Run Code Online (Sandbox Code Playgroud)

android web-services httpclient http-post

5
推荐指数
1
解决办法
1万
查看次数

ModelBinding:MVC4/C中的POST数据(可能来自Ruby)#

我们正在与chargify http://www.chargify.com集成,我需要在我们的MVC4/C#服务器中处理来自Chargify的webhooks.Chargify以(ruby)方式发送POST数据 - 子对象在方括号中分隔,如下所示:

POST /1ffaj2f1 HTTP/1.1
X-Chargify-Webhook-Signature: 526ccfd9677668674eaa6ba5d447e93a
X-Chargify-Webhook-Id: 11238622
User-Agent: Ruby
Host: requestb.in
Content-Type: application/x-www-form-urlencoded
Content-Length: 5159
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*; q=0.5, application/xml

id=11238622&event=payment_success&payload[subscription][activated_at]=2013-05-22%2001%3A25%3A20%20-0400&payload[subscription][balance_in_cents]=0&...
Run Code Online (Sandbox Code Playgroud)

问题是在.NET端,默认模型绑定器不喜欢方括号[ ],而是期望子对象以点分表示方式分隔a.b.c.d=value

我有什么选择让模型绑定器工作?我能想到以下几点:

  1. 使用委托处理程序挂钩请求,读取req主体并将[]替换为点(.).然而,这至少让人感到有点冒险
  2. 编写一个可以使用的自定义模型绑定器[]- 希望能够以某种方式委托给默认处理程序.不知道如何解决这个问题 - 但很想听到一些想法.
  3. 只需formcollection在Action中使用一个参数.处理表单集合键以基于键形成递归字典.这也意味着我必须处理整个字符串(日期,ids等等)

什么是最好的方式,我该如何去做.

c# http-post model-binding asp.net-mvc-4

5
推荐指数
1
解决办法
509
查看次数

Google Flight RPC和构建JSON数组

我正在尝试使用Google Flight RPC,但是无法构建一个json数组来发布它.我发现的唯一文件就在这里.它描述了需要发送的内容,但没有解释如何构造json数组.具体来说,使用PHP,我不知道如何使用链接文档的第1部分中的以下示例构建和发布json数组.

[,[[,"fs","[,[,[\"SJC\"]\n,\"2012-04-05\",[\"EWR\",\"JFK\",\"LGA\"]\n,\"2012-04-12\"]\n]\n"]
]
,[,[[,"b_ca","54"]
,[,"f_ut","search;f=SJC;t=EWR,JFK,LGA;d=2012-04-05;r=2012-04-12"]
,[,"b_lr","11:36"]
,[,"b_lr","1:1528"]
,[,"b_lr","2:1827"]
,[,"b_qu","3"]
,[,"b_qc","1"]
]
]
] 
Run Code Online (Sandbox Code Playgroud)

上面似乎没有正确格式化以放入json数组.此外,还需要HTTP请求标头.我假设这些是通过cURL设置的?我不清楚有关如何执行此操作的文档.

我已经尝试了几次尝试,但我没有收到文档中显示的任何响应.

编辑:太棒了,我为这个问题买了一个Tumbleweed徽章!我很感激帮助.谢谢.

php rpc json curl http-post

5
推荐指数
1
解决办法
922
查看次数

Rails/Redmine - 无法验证422错误中的真实性令牌结果

我正在为Redmine平台开发插件,我想使用链接而不是表单将文件附加到文档(基本上上传文件),为此我在方法中创建POST请求.

我按照这里的说明,将内容类型设置application/octet-stream为请求,然后将文件内容放在请求正文中.

我在这个网站上看了很多帖子,我知道这经常被问到但是我无法正确地处理我的请求,我仍然会收到错误.这是我的代码:

uri = URI.parse("http://<my_server_IP_address>:3000/uploads.js")

http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.path, initheader = {'X-CSRF-Token' => form_authenticity_token, 'Content-Type' => 'application/octet-stream'})
file = File.new("/home/testFile.txt", 'rb')
request.body = file.read
@response = http.request(request)
Run Code Online (Sandbox Code Playgroud)

如您所见,我使用该form_authenticity_token方法在标头中设置CSRF令牌,但我仍然收到422错误.

Filter chain halted as :verify_authenticity_token rendered or redirected
Completed 422 Unprocessable Entity in 4.7ms (ActiveRecord: 0.0ms)
Run Code Online (Sandbox Code Playgroud)

我也试着把skip_before_filter :verify_authenticity_token我的控制器打开,尽管不推荐,但它也没有用.

你知道这里有什么问题吗?

注意:我正在使用Rails 3.2.16,Ruby 1.9.3-p392和Redmine 2.4.2

ruby ruby-on-rails http-post redmine redmine-plugins

5
推荐指数
0
解决办法
1482
查看次数

过滤后提交所有表单数据

我在表单内有一个html表。我将DataTables应用于表以添加过滤和排序。这很好。

唯一的问题是,如果用户在搜索框中输入数据进行过滤,然后提交表单,则仅提交可见行。我以为DataTables只是隐藏了由搜索过滤的行,因此所有内容都应该以表格的形式存在,但事实并非如此。

即使用户碰巧启用了搜索过滤器,也可以通过表单发布所有行吗?

forms jquery http-post filter datatables

5
推荐指数
1
解决办法
1128
查看次数

如何使用GitLab API创建MR?

我正在尝试使用GitLab合并请求API和python和python请求包创建合并请求。这是我的代码的一部分

import requests, json

MR = 'http://www.gitlab.com/api/v4/projects/317/merge_requests'

id = '317'
gitlabAccessToken = 'MySecretAccessToken'
sourceBranch = 'issue110'
targetBranch = 'master'
title = 'title'
description = 'description'

header = { 'PRIVATE-TOKEN' : gitlabAccessToken,
           'id'            : id,    
           'title'         : title, 
           'source_branch' : sourceBranch, 
           'target_branch' : targetBranch
         }

reply = requests.post(MR, headers = header)
status = json.loads(reply.text)
Run Code Online (Sandbox Code Playgroud)

但我在回复中不断收到以下消息

{'error': 'title is missing, source_branch is missing, target_branch is missing'}
Run Code Online (Sandbox Code Playgroud)

我应该更改其要求以使其正常工作吗?

python http-post python-requests gitlab gitlab-api

5
推荐指数
1
解决办法
738
查看次数

如何正确使用AngularJS $ http.post通过PHP更新MySQLi表?

我想achievements通过PHP 更新MySQLi表.该应用程序在AngularJS中编码并测量各种统计数据.当达到目标时,我使用AngularJS将信息发送到PHP脚本$http.post.然后PHP应该处理信息并相应地更新我的表.在$http.post返回成功消息,但没有更新的表.我相信数据库连接信息是正确的.

我的AngularJS $scope.updatePhp函数使用$http.post:

$scope.updatePhp = function(table, column, value, whereColumn, whereValue) {
    $http.post(
        "update-data.php", {
            'table': table,
            'column': column,
            'value': value,
            'whereColumn': whereColumn,
            'whereValue': whereValue
        }
    );
}
Run Code Online (Sandbox Code Playgroud)

我的AngularJS $scope.updatePhp功能没有使用.post快捷方式:

$scope.updatePhp = function(table, column, value, whereColumn, whereValue) {

    console.log("Updating. Table: " + table + ", column: " + column + ", value: " + value + ", where: " + whereColumn + ", whereValue: " + whereValue);

    $http({ …
Run Code Online (Sandbox Code Playgroud)

php post mysqli http-post angularjs

5
推荐指数
1
解决办法
121
查看次数