(*** SOLVED ***)
(Issue regarded a WAMP configuration setting. See my fourth response.)
Hi,
I have a working app that uses Soap to connect to an API. Everything is working fine. I can properly connected, make requests, receive requests, etc.
I’m now working on building out the Console part of the application to handle some scheduled tasks. However, when I tried to make a basic connection in my ConsoleCommand, I get the following error:
PHP Error[2]: include(SoapClient.php): failed to open stream: No such file or directory
Not really sure why this is happening. Is there some sublty when running PHP in a console? Are there settings in some .ini file somewhere? As I mentioned, the Soap connection is working perfectly fine for the web-app.
Here is my Console Command (you’ll see it’s quite simple)
class PacingCommand extends CConsoleCommand
{
public function run($args)
{
// Preparation
$date = new DateTime();
$OAS = new OASApi();
$date->modify('-1 day');
$campaignList = $OAS->listCampaigns(array(
'startDate' =>$date->format('Y-m-d'),
'endDate' => $date->format('Y-m-d'),
'IDFilter' => 'IP',
'status' => '',
));
}
}
And the OAS API wrapper that contains the Soap declarations.
class OASApi {
private $_SOAPUrl = "***The_URL***";
private $_client;
private $_OASUsername = '***';
private $_OASAccount = '***';
private $_OASPassword = '***';
//Function to make a call to get the list of campaigns for a given date.
//Expects:
// "startDate" and "endDate" passed in parameter array. Both in format 'Y-m-d'.
// "IDFilter" (string to filter campaign IDs).
// Function Returns a Simple XML object containing the results of the query.
public function listCampaigns($params)
{
$adXML = '<AdXML>
<Request type="Campaign">
<Campaign action="list">
<SearchCriteria>
<Status>'.$params['status'].'</Status>
<Id>'.$params['IDFilter'].'</Id>
<StartDate condition="LE">'.$params['startDate'].'</StartDate>
<EndDate condition="GE">'.$params['endDate'].'</EndDate>
</SearchCriteria>
</Campaign>
</Request>
</AdXML>';
return simplexml_load_string($this->_client->OASXmlRequest($this->_OASUsername, $this->_OASAccount, $this->_OASPassword, $adXML));
}
function __construct() {
try {
$this->_client = new SoapClient($this->_SOAPUrl);
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
}
}