Api tester
http://localhost/api/index.php?action=list&object=categorias
OK
curl from command line
curl -i -X GET "http://localhost/api/index.php?action=list&object=categorias"
OK
But
i can't make it works inside a PHP with Curl:
$params= array( 'action'=>'list','object'=>'categorias');
$prod = json_decode(Send2Api($url,$params));
function Send2Api($url,$data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
......
BUT WORKS ON SERVER.
JUST NOT WORKS ONLY IN localhost
Can you check console for errors? Like CORS
Try passing the url and parameters directly Like http://localhost/api/index.php?action=list&object=categorias In the curl_init function
Обсуждают сегодня