1

我不是很精通curl,想知道是否有人可以帮助我将以下内容转换为php:

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"tester":{"email":"justin@prefinery.com","status":"applied","profile":{"first_name": "Justin", "last_name": "Britten"},"responses":{"response":[{"question_id":"23874", "answer":"a text response"},{"question_id":"23871", "answer":"1"},{"question_id":"23872", "answer":"0,2"},{"question_id":"23873", "answer":"9"}]}}}' https://account.prefinery.com/api/v2/betas/1/testers.json?api_key=secret

如果你知道一个好的 curl 教程也会有很大的帮助。

4

1 回答 1

0

像这样的东西

 $ch = curl_init();
            $json = '{"tester":{"email":"justin@prefinery.com","status":"applied","profile":{"first_name": "Justin", "last_name": "Britten"},"responses":{"response":[{"question_id":"23874", "answer":"a text response"},{"question_id":"23871", "answer":"1"},{"question_id":"23872", "answer":"0,2"},{"question_id":"23873", "answer":"9"}]}}}';
            $url = 'https://account.prefinery.com/api/v2/betas/1/testers.json?api_key=secret';
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json', 'Accept: application/json'));
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            $result = curl_exec($ch);
于 2013-02-18T17:01:20.753 回答