Reputation: 946
I am using Laravel and I am attempting to make an https request (this works on localhost) but now I am putting on a server. I have been advised that I will need to setup configuration to route through a proxy server. I have been provided with a URL and Port.
Apparently these need setting up for any part of the system that attempts to connect externally. I was advised that there may be a config file for variables/constants, thought the person that provided me this information could not say what variables need to be set in Laravel.
I believe I may need to add to the routes/api.php having read the laravel guide for routing but this is not clear to me. For example it says:
Available Router Methods
The router allows you to register routes that respond to any HTTP verb:
Route::get($uri, $callback);
But it is not clear to me what I am putting there. Could it be the request to dev.tescolabs or the url and port information?
I have done web routes before eg. Route::get('/list', 'IngredientsController@display');
but this extra step is confusing.
My code which works locally is:
<?php
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://dev.tescolabs.com/product/');
$url = $request->getUrl();
$headers = array(
// Request headers
'Ocp-Apim-Subscription-Key' => 'key',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
// 'tpnb' => '{string}',
// 'tpnc' => '{string}',
// 'catid' => '{string}',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
$result = $response->getBody();
Upvotes: 2
Views: 8898
Reputation: 946
Above the line:$url = $request->getUrl();
I added the below:
$request->setConfig(array(
'proxy_host' => 'wwwproxy.address',
'proxy_port' => port number
));
Upvotes: 1