如何在PHP中使用Curl调用不同的API

时间:2015-01-07 21:35:15

标签: php curl response

单击它时有一个按钮,它将Post数据发送到php文件,并根据按钮的方法,它将使用switch语句触发该方法。例如:

$php_postdata->method ='clean';

switch($php_postdata->method){
case 'clean':
 $url = 'urlwithapi.com';
 $data = '{"name":"'. $php_postdata->name. '}';
 break;
}
$haders = 'blah blah blah';
$ch = curl_init();
 .....
 ......
  curl_setopt(); items
curl gets executed.
curl_close($ch);
 $json_response = json_encode($php_response);
//echo out the response
 echo($jsonresponse);

我的问题是,如何在第一次传递后重新运行此脚本,我想使用“clean”方法的响应向switch语句添加另一个方法,并回显该响应。

欢迎任何建议。

感谢

0 个答案:

没有答案
相关问题