小编fre*_*d00的帖子

curl -X POST -H'Content-Type:application/json' -d to PHP

我需要做一个curl请求,我有这行"curl -X POST -H'Content-Type:application/json'-d"并且需要"翻译"到PHP curl.问题是我不知道"-X"," - H"和"-d"是什么意思.

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Accept: application/json',
        'Content-Type: application/json',
        'Content-Length: '. strlen($itemJson))
    );
Run Code Online (Sandbox Code Playgroud)

我在标题上尝试了类似的东西($itemJson是一个JSON字符串),但我得到错误400.

我想我是以错误的方式做这个请求的.有谁能够帮我?

php curl

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

无法分配给对象'#<ValidationComponent>'的只读属性'dataChange'

我试图在Angular 4中使用双向绑定.这是我的组件代码:

@Component({
    selector: 'form-validation',
    templateUrl: './form.validation.template.html',
    encapsulation: ViewEncapsulation.None
})

export class ValidationComponent {

    @Input() data;

    @Output dataChange = new EventEmitter();

    //...

}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试在类似的东西上使用它时:

<form-validation [(data)]="data"></form-validation>
Run Code Online (Sandbox Code Playgroud)

我在Chrome的控制台上收到此错误:

Cannot assign to read only property 'dataChange' of object '#<ValidationComponent>'
Run Code Online (Sandbox Code Playgroud)

data属性是一个特定类型的数组,但即使我通知此类型或inicialize属性错误发生.

angular two-way-binding

8
推荐指数
1
解决办法
840
查看次数

接收JSON POST

可能重复:
如何在PHP中获取POST的正文?

我收到一个包含JSON的POST,问题是当我收到$ _POST为空时.为了测试我何时收到POST,我创建了一个包含$ _POST,$ _GET和$ _REQUEST的文件,它们都是空的.

发送请求的客户端正在执行以下操作:

$itemJson = '{
      "id": 00,
      "value": "ok"
    }';

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: '. strlen($itemJson))
    );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $itemJson);
    curl_close($ch);
Run Code Online (Sandbox Code Playgroud)

说实话,我不明白我是如何得到这些数据的,因为没有参数设置.

有任何想法吗?

php post json curl

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

量角器超时等待存在的元素

我在Angular 2应用程序中开始一些测试,在第一次测试中我遇到了一些问题.

我想测试登录页面,所以我想填写电子邮件.这是我的测试代码:

describe('login page', function() {
    it('should login', function() {

        browser.get('http://localhost:3000/#/login');

        element(by.css('.form-control.ng-pristine.ng-valid.ng-untouched')).sendKeys('test@test.com');

    });
});
Run Code Online (Sandbox Code Playgroud)

我的渲染HTML代码是:

<form class="login-form mt-lg ng-pristine ng-valid ng-touched">
   <!--template bindings={}-->
   <!--template bindings={}-->
   <div class="form-group">
     <input class="form-control ng-pristine ng-valid ng-touched" name="email" placeholder="E-mail" type="email">
   </div>
   <div class="form-group">
     <input class="form-control ng-untouched ng-pristine ng-valid" name="password" placeholder="Password" type="password">
   </div>
 <div class="clearfix">
    <div class="btn-toolbar float-xs-right m-t-1">
     <button class="btn btn-primary btn-sm" type="submit">Log in</button>
    </div>
    <div class="float-xs-left m-t-1">
      <a class="mt help-block">Forgot your password?</a>
    </div>
  </div>
</form>
Run Code Online (Sandbox Code Playgroud)

"原始"HTML代码是:

<form class="login-form mt-lg" (ngSubmit)="login($event)">
  <div *ngIf="error" class="alert …
Run Code Online (Sandbox Code Playgroud)

angularjs protractor angular

3
推荐指数
1
解决办法
2634
查看次数

docker-compose down 失败:打开的文件太多

我在生产服务器中使用 docker-compose。在我的部署过程中,我运行docker-compose down、部署应用程序并运行docker-compose up。但是,当我docker-compose down这样做时,它会返回类似的内容:

ERROR: for ubuntu_php_run_1105  ('Connection aborted.', error(24, 'Too many open files'))

ERROR: for ubuntu_php_run_821  ('Connection aborted.', error(24, 'Too many open files'))

ERROR: for ubuntu_php_run_820  ('Connection aborted.', error(24, 'Too many open files'))
Run Code Online (Sandbox Code Playgroud)

如果我多次手动运行此命令,最终它会成功,但我需要修复它,因为此错误会使我的部署过程失败。

docker docker-compose

3
推荐指数
1
解决办法
6330
查看次数