我有这样的代码。
<?php
$post_vars = array('app_key'=>'my_api_key', 'user_key' => 'my_user_key');
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($c, CURLOPT_URL, 'http://hellotxt.com/api/v1/method/user.validate');
curl_setopt($c, CURLOPT_POSTFIELDS, $post_vars);
$content = curl_exec($c);
print_r($content);
curl_close($c);
?>
这会将返回响应显示为“未指定应用程序键”。但是,如果我通过表单 (form-post) 发布 api 密钥和用户密钥,则同样有效。当我使用表单提交 api 密钥和用户密钥时,我得到的响应为。
<rsp status="OK"><nick>testinguser</nick><name>testinguser</name><avatar> http://hellotxt.com/avatar/testinguser/medium/image.jpg</avatar></rsp>
但我不能用卷曲做。什么地方出了错。请指导我谢谢Haan(PS:FYI,hellotxt的api在这里。http: //hellotxt.com/developers/api)