Reputation: 81
I have developed some API using laravel and created a virtual host on my local machine.
like abc.xyz.com/api/v1/oauth2/token for getting oauth token. Now I want to test these API
from another local app say abc.com using curl.
I am not getting any response .How can I do this ?Where both apps are in my local machine.
Upvotes: 0
Views: 382
Reputation: 81
I got the answer for my question myself. Actually I forgot to add / at the end of URL that why is was not giving any response .
Thanks to All for Help
Upvotes: 0
Reputation: 87719
Curl will give you a lot of trouble to do many things, use Guzzle to consume your API. It's simple, it has it all figured out and it works:
Install
composer require "guzzlehttp/guzzle" "~4.0"
Create a client:
$client = new \GuzzleHttp\Client();
Get results:
$response = $client->get('http://abc.example.com/api/v1/oauth2/token');
dd($response->getBody());
Project: https://github.com/guzzle/guzzle
Upvotes: 1