The path of the libraries directory of my codeigniter project is like what shown in the image.
I tried to load Facebook.php class using these following codes, but both of them returned the same error : Unable to load the requested class: Facebook
$this->load->library('facebook/facebook', $fb_config);
or
$this->load->library('Facebook/Facebook', $fb_config);
This is so frustrating, the class Facebook.php is clearly there.
Why codeigniter is unable to load the classes under a subfolder of libraries ?
Meanwhile it works fine with the classes in libraries root (without subfolder).
This is what inside Facebook.php
<?php
/**
* Copyright 2014 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
* form for use in connection with the web services and APIs provided by
* Facebook.
*
* As with any software that integrates with the Facebook platform, your use
* of this software is subject to the Facebook Developer Principles and
* Policies [http://developers.facebook.com/policy/]. This copyright notice
* shall be included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace Facebook;
use Facebook\Authentication\AccessToken;
use Facebook\Authentication\OAuth2Client;
use Facebook\FileUpload\FacebookFile;
use Facebook\FileUpload\FacebookVideo;
use Facebook\GraphNodes\GraphEdge;
use Facebook\Url\UrlDetectionInterface;
use Facebook\Url\FacebookUrlDetectionHandler;
use Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface;
use Facebook\PseudoRandomString\McryptPseudoRandomStringGenerator;
use Facebook\PseudoRandomString\OpenSslPseudoRandomStringGenerator;
use Facebook\PseudoRandomString\UrandomPseudoRandomStringGenerator;
use Facebook\HttpClients\FacebookHttpClientInterface;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookStreamHttpClient;
use Facebook\HttpClients\FacebookGuzzleHttpClient;
use Facebook\PersistentData\PersistentDataInterface;
use Facebook\PersistentData\FacebookSessionPersistentDataHandler;
use Facebook\PersistentData\FacebookMemoryPersistentDataHandler;
use Facebook\Helpers\FacebookCanvasHelper;
use Facebook\Helpers\FacebookJavaScriptHelper;
use Facebook\Helpers\FacebookPageTabHelper;
use Facebook\Helpers\FacebookRedirectLoginHelper;
use Facebook\Exceptions\FacebookSDKException;
/**
* Class Facebook
*
* #package Facebook
*/
class Facebook
{
/**
* #const string Version number of the Facebook PHP SDK.
*/
const VERSION = '5.0.0';
/**
* #const string Default Graph API version for requests.
*/
const DEFAULT_GRAPH_VERSION = 'v2.4';
/**
* #const string The name of the environment variable that contains the app ID.
*/
const APP_ID_ENV_NAME = 'FACEBOOK_APP_ID';
/**
* #const string The name of the environment variable that contains the app secret.
*/
const APP_SECRET_ENV_NAME = 'FACEBOOK_APP_SECRET';
/**
* #var FacebookApp The FacebookApp entity.
*/
protected $app;
/**
* #var FacebookClient The Facebook client service.
*/
protected $client;
/**
* #var OAuth2Client The OAuth 2.0 client service.
*/
protected $oAuth2Client;
/**
* #var UrlDetectionInterface|null The URL detection handler.
*/
protected $urlDetectionHandler;
/**
* #var PseudoRandomStringGeneratorInterface|null The cryptographically secure pseudo-random string generator.
*/
protected $pseudoRandomStringGenerator;
/**
* #var AccessToken|null The default access token to use with requests.
*/
protected $defaultAccessToken;
/**
* #var string|null The default Graph version we want to use.
*/
protected $defaultGraphVersion;
/**
* #var PersistentDataInterface|null The persistent data handler.
*/
protected $persistentDataHandler;
/**
* #var FacebookResponse|FacebookBatchResponse|null Stores the last request made to Graph.
*/
protected $lastResponse;
/**
* Instantiates a new Facebook super-class object.
*
* #param array $config
*
* #throws FacebookSDKException
*/
public function __construct(array $config = [])
{
$appId = isset($config['app_id']) ? $config['app_id'] : getenv(static::APP_ID_ENV_NAME);
if (!$appId) {
throw new FacebookSDKException('Required "app_id" key not supplied in config and could not find fallback environment variable "' . static::APP_ID_ENV_NAME . '"');
}
$appSecret = isset($config['app_secret']) ? $config['app_secret'] : getenv(static::APP_SECRET_ENV_NAME);
if (!$appSecret) {
throw new FacebookSDKException('Required "app_secret" key not supplied in config and could not find fallback environment variable "' . static::APP_SECRET_ENV_NAME . '"');
}
$this->app = new FacebookApp($appId, $appSecret);
$httpClientHandler = null;
if (isset($config['http_client_handler'])) {
if ($config['http_client_handler'] instanceof FacebookHttpClientInterface) {
$httpClientHandler = $config['http_client_handler'];
} elseif ($config['http_client_handler'] === 'curl') {
$httpClientHandler = new FacebookCurlHttpClient();
} elseif ($config['http_client_handler'] === 'stream') {
$httpClientHandler = new FacebookStreamHttpClient();
} elseif ($config['http_client_handler'] === 'guzzle') {
$httpClientHandler = new FacebookGuzzleHttpClient();
} else {
throw new \InvalidArgumentException('The http_client_handler must be set to "curl", "stream", "guzzle", or be an instance of Facebook\HttpClients\FacebookHttpClientInterface');
}
}
$enableBeta = isset($config['enable_beta_mode']) && $config['enable_beta_mode'] === true;
$this->client = new FacebookClient($httpClientHandler, $enableBeta);
if (isset($config['url_detection_handler'])) {
if ($config['url_detection_handler'] instanceof UrlDetectionInterface) {
$this->urlDetectionHandler = $config['url_detection_handler'];
} else {
throw new \InvalidArgumentException('The url_detection_handler must be an instance of Facebook\Url\UrlDetectionInterface');
}
}
if (isset($config['pseudo_random_string_generator'])) {
if ($config['pseudo_random_string_generator'] instanceof PseudoRandomStringGeneratorInterface) {
$this->pseudoRandomStringGenerator = $config['pseudo_random_string_generator'];
} elseif ($config['pseudo_random_string_generator'] === 'mcrypt') {
$this->pseudoRandomStringGenerator = new McryptPseudoRandomStringGenerator();
} elseif ($config['pseudo_random_string_generator'] === 'openssl') {
$this->pseudoRandomStringGenerator = new OpenSslPseudoRandomStringGenerator();
} elseif ($config['pseudo_random_string_generator'] === 'urandom') {
$this->pseudoRandomStringGenerator = new UrandomPseudoRandomStringGenerator();
} else {
throw new \InvalidArgumentException('The pseudo_random_string_generator must be set to "mcrypt", "openssl", or "urandom", or be an instance of Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface');
}
}
if (isset($config['persistent_data_handler'])) {
if ($config['persistent_data_handler'] instanceof PersistentDataInterface) {
$this->persistentDataHandler = $config['persistent_data_handler'];
} elseif ($config['persistent_data_handler'] === 'session') {
$this->persistentDataHandler = new FacebookSessionPersistentDataHandler();
} elseif ($config['persistent_data_handler'] === 'memory') {
$this->persistentDataHandler = new FacebookMemoryPersistentDataHandler();
} else {
throw new \InvalidArgumentException('The persistent_data_handler must be set to "session", "memory", or be an instance of Facebook\PersistentData\PersistentDataInterface');
}
}
if (isset($config['default_access_token'])) {
$this->setDefaultAccessToken($config['default_access_token']);
}
if (isset($config['default_graph_version'])) {
$this->defaultGraphVersion = $config['default_graph_version'];
} else {
// #todo v6: Throw an InvalidArgumentException if "default_graph_version" is not set
$this->defaultGraphVersion = static::DEFAULT_GRAPH_VERSION;
}
}
/**
* Returns the FacebookApp entity.
*
* #return FacebookApp
*/
public function getApp()
{
return $this->app;
}
/**
* Returns the FacebookClient service.
*
* #return FacebookClient
*/
public function getClient()
{
return $this->client;
}
/**
* Returns the OAuth 2.0 client service.
*
* #return OAuth2Client
*/
public function getOAuth2Client()
{
if (!$this->oAuth2Client instanceof OAuth2Client) {
$app = $this->getApp();
$client = $this->getClient();
$this->oAuth2Client = new OAuth2Client($app, $client, $this->defaultGraphVersion);
}
return $this->oAuth2Client;
}
/**
* Returns the last response returned from Graph.
*
* #return FacebookResponse|FacebookBatchResponse|null
*/
public function getLastResponse()
{
return $this->lastResponse;
}
/**
* Returns the URL detection handler.
*
* #return UrlDetectionInterface
*/
public function getUrlDetectionHandler()
{
if (!$this->urlDetectionHandler instanceof UrlDetectionInterface) {
$this->urlDetectionHandler = new FacebookUrlDetectionHandler();
}
return $this->urlDetectionHandler;
}
/**
* Returns the default AccessToken entity.
*
* #return AccessToken|null
*/
public function getDefaultAccessToken()
{
return $this->defaultAccessToken;
}
/**
* Sets the default access token to use with requests.
*
* #param AccessToken|string $accessToken The access token to save.
*
* #throws \InvalidArgumentException
*/
public function setDefaultAccessToken($accessToken)
{
if (is_string($accessToken)) {
$this->defaultAccessToken = new AccessToken($accessToken);
return;
}
if ($accessToken instanceof AccessToken) {
$this->defaultAccessToken = $accessToken;
return;
}
throw new \InvalidArgumentException('The default access token must be of type "string" or Facebook\AccessToken');
}
/**
* Returns the default Graph version.
*
* #return string
*/
public function getDefaultGraphVersion()
{
return $this->defaultGraphVersion;
}
/**
* Returns the redirect login helper.
*
* #return FacebookRedirectLoginHelper
*/
public function getRedirectLoginHelper()
{
return new FacebookRedirectLoginHelper(
$this->getOAuth2Client(),
$this->persistentDataHandler,
$this->urlDetectionHandler,
$this->pseudoRandomStringGenerator
);
}
/**
* Returns the JavaScript helper.
*
* #return FacebookJavaScriptHelper
*/
public function getJavaScriptHelper()
{
return new FacebookJavaScriptHelper($this->app, $this->client, $this->defaultGraphVersion);
}
/**
* Returns the canvas helper.
*
* #return FacebookCanvasHelper
*/
public function getCanvasHelper()
{
return new FacebookCanvasHelper($this->app, $this->client, $this->defaultGraphVersion);
}
/**
* Returns the page tab helper.
*
* #return FacebookPageTabHelper
*/
public function getPageTabHelper()
{
return new FacebookPageTabHelper($this->app, $this->client, $this->defaultGraphVersion);
}
/**
* Sends a GET request to Graph and returns the result.
*
* #param string $endpoint
* #param AccessToken|string|null $accessToken
* #param string|null $eTag
* #param string|null $graphVersion
*
* #return FacebookResponse
*
* #throws FacebookSDKException
*/
public function get($endpoint, $accessToken = null, $eTag = null, $graphVersion = null)
{
return $this->sendRequest(
'GET',
$endpoint,
$params = [],
$accessToken,
$eTag,
$graphVersion
);
}
/**
* Sends a POST request to Graph and returns the result.
*
* #param string $endpoint
* #param array $params
* #param AccessToken|string|null $accessToken
* #param string|null $eTag
* #param string|null $graphVersion
*
* #return FacebookResponse
*
* #throws FacebookSDKException
*/
public function post($endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
{
return $this->sendRequest(
'POST',
$endpoint,
$params,
$accessToken,
$eTag,
$graphVersion
);
}
/**
* Sends a DELETE request to Graph and returns the result.
*
* #param string $endpoint
* #param array $params
* #param AccessToken|string|null $accessToken
* #param string|null $eTag
* #param string|null $graphVersion
*
* #return FacebookResponse
*
* #throws FacebookSDKException
*/
public function delete($endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
{
return $this->sendRequest(
'DELETE',
$endpoint,
$params,
$accessToken,
$eTag,
$graphVersion
);
}
/**
* Sends a request to Graph for the next page of results.
*
* #param GraphEdge $graphEdge The GraphEdge to paginate over.
*
* #return GraphEdge|null
*
* #throws FacebookSDKException
*/
public function next(GraphEdge $graphEdge)
{
return $this->getPaginationResults($graphEdge, 'next');
}
/**
* Sends a request to Graph for the previous page of results.
*
* #param GraphEdge $graphEdge The GraphEdge to paginate over.
*
* #return GraphEdge|null
*
* #throws FacebookSDKException
*/
public function previous(GraphEdge $graphEdge)
{
return $this->getPaginationResults($graphEdge, 'previous');
}
/**
* Sends a request to Graph for the next page of results.
*
* #param GraphEdge $graphEdge The GraphEdge to paginate over.
* #param string $direction The direction of the pagination: next|previous.
*
* #return GraphEdge|null
*
* #throws FacebookSDKException
*/
public function getPaginationResults(GraphEdge $graphEdge, $direction)
{
$paginationRequest = $graphEdge->getPaginationRequest($direction);
if (!$paginationRequest) {
return null;
}
$this->lastResponse = $this->client->sendRequest($paginationRequest);
// Keep the same GraphNode subclass
$subClassName = $graphEdge->getSubClassName();
$graphEdge = $this->lastResponse->getGraphEdge($subClassName, false);
return count($graphEdge) > 0 ? $graphEdge : null;
}
/**
* Sends a request to Graph and returns the result.
*
* #param string $method
* #param string $endpoint
* #param array $params
* #param AccessToken|string|null $accessToken
* #param string|null $eTag
* #param string|null $graphVersion
*
* #return FacebookResponse
*
* #throws FacebookSDKException
*/
public function sendRequest($method, $endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
{
$accessToken = $accessToken ?: $this->defaultAccessToken;
$graphVersion = $graphVersion ?: $this->defaultGraphVersion;
$request = $this->request($method, $endpoint, $params, $accessToken, $eTag, $graphVersion);
return $this->lastResponse = $this->client->sendRequest($request);
}
/**
* Sends a batched request to Graph and returns the result.
*
* #param array $requests
* #param AccessToken|string|null $accessToken
* #param string|null $graphVersion
*
* #return FacebookBatchResponse
*
* #throws FacebookSDKException
*/
public function sendBatchRequest(array $requests, $accessToken = null, $graphVersion = null)
{
$accessToken = $accessToken ?: $this->defaultAccessToken;
$graphVersion = $graphVersion ?: $this->defaultGraphVersion;
$batchRequest = new FacebookBatchRequest(
$this->app,
$requests,
$accessToken,
$graphVersion
);
return $this->lastResponse = $this->client->sendBatchRequest($batchRequest);
}
/**
* Instantiates a new FacebookRequest entity.
*
* #param string $method
* #param string $endpoint
* #param array $params
* #param AccessToken|string|null $accessToken
* #param string|null $eTag
* #param string|null $graphVersion
*
* #return FacebookRequest
*
* #throws FacebookSDKException
*/
public function request($method, $endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
{
$accessToken = $accessToken ?: $this->defaultAccessToken;
$graphVersion = $graphVersion ?: $this->defaultGraphVersion;
return new FacebookRequest(
$this->app,
$accessToken,
$method,
$endpoint,
$params,
$eTag,
$graphVersion
);
}
/**
* Factory to create FacebookFile's.
*
* #param string $pathToFile
*
* #return FacebookFile
*
* #throws FacebookSDKException
*/
public function fileToUpload($pathToFile)
{
return new FacebookFile($pathToFile);
}
/**
* Factory to create FacebookVideo's.
*
* #param string $pathToFile
*
* #return FacebookVideo
*
* #throws FacebookSDKException
*/
public function videoToUpload($pathToFile)
{
return new FacebookVideo($pathToFile);
}
}
Note : I am using Ubuntu OS
just use
$this->load->library('facebook/facebook'); // Automatically picks appId and secret from config
// OR
// You can pass different one like this
$this->load->library('facebook/facebook', array(
'appId' => 'APP_ID',
'secret' => 'SECRET',
));
and inside facebook.php class name should be
class Facebook {
Facebook SDK PHP v4 & CodeIgniter and github download
$this->load->library('Facebook\facebook', array('app_id' => 'your value', 'app_secret' => 'your value'));
I did this and the problem was solved (on windows machine) And also add
require_once("autoload.php")
on Facebook class just below namespace so your can get rid of other exception related errors.
Related
I'm trying to create my first Magento 2 extension and integration and I've been following the guide in their docs here. All good so far, I've completed the auth handshake, stored all the required keys for api requests and can make requests back to my extension fine.
Looking at the OauthClient.php script provided at the foot of the tutorial, the url is hardcoded like so:
return new Uri('http://magento.host/oauth/token/request'); and the tutorial advises you to "Change the instances of http://magento.host in this example to a valid base URL."
<?php
use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Http\Client\ClientInterface;
use OAuth\Common\Http\Exception\TokenResponseException;
use OAuth\Common\Http\Uri\Uri;
use OAuth\Common\Http\Uri\UriInterface;
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\OAuth1\Service\AbstractService;
use OAuth\OAuth1\Signature\SignatureInterface;
use OAuth\OAuth1\Token\StdOAuth1Token;
use OAuth\OAuth1\Token\TokenInterface;
class OauthClient extends AbstractService
{
/** #var string|null */
protected $_oauthVerifier = null;
public function __construct(
Credentials $credentials,
ClientInterface $httpClient = null,
TokenStorageInterface $storage = null,
SignatureInterface $signature = null,
UriInterface $baseApiUri = null
) {
if (!isset($httpClient)) {
$httpClient = new \OAuth\Common\Http\Client\StreamClient();
}
if (!isset($storage)) {
$storage = new \OAuth\Common\Storage\Session();
}
if (!isset($signature)) {
$signature = new \OAuth\OAuth1\Signature\Signature($credentials);
}
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
}
/**
* #return UriInterface
*/
public function getRequestTokenEndpoint()
{
return new Uri('http://magento.host/oauth/token/request');
}
/**
* Returns the authorization API endpoint.
*
* #throws \OAuth\Common\Exception\Exception
*/
public function getAuthorizationEndpoint()
{
throw new \OAuth\Common\Exception\Exception(
'Magento REST API is 2-legged. Current operation is not available.'
);
}
/**
* Returns the access token API endpoint.
*
* #return UriInterface
*/
public function getAccessTokenEndpoint()
{
return new Uri('http://magento.host/oauth/token/access');
}
/**
* Parses the access token response and returns a TokenInterface.
*
* #param string $responseBody
* #return TokenInterface
*/
protected function parseAccessTokenResponse($responseBody)
{
return $this->_parseToken($responseBody);
}
/**
* Parses the request token response and returns a TokenInterface.
*
* #param string $responseBody
* #return TokenInterface
* #throws TokenResponseException
*/
protected function parseRequestTokenResponse($responseBody)
{
$data = $this->_parseResponseBody($responseBody);
if (isset($data['oauth_verifier'])) {
$this->_oauthVerifier = $data['oauth_verifier'];
}
return $this->_parseToken($responseBody);
}
/**
* Parse response body and create oAuth token object based on parameters provided.
*
* #param string $responseBody
* #return StdOAuth1Token
* #throws TokenResponseException
*/
protected function _parseToken($responseBody)
{
$data = $this->_parseResponseBody($responseBody);
$token = new StdOAuth1Token();
$token->setRequestToken($data['oauth_token']);
$token->setRequestTokenSecret($data['oauth_token_secret']);
$token->setAccessToken($data['oauth_token']);
$token->setAccessTokenSecret($data['oauth_token_secret']);
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
unset($data['oauth_token'], $data['oauth_token_secret']);
$token->setExtraParams($data);
return $token;
}
/**
* Parse response body and return data in array.
*
* #param string $responseBody
* #return array
* #throws \OAuth\Common\Http\Exception\TokenResponseException
*/
protected function _parseResponseBody($responseBody)
{
if (!is_string($responseBody)) {
throw new TokenResponseException("Response body is expected to be a string.");
}
parse_str($responseBody, $data);
if (null === $data || !is_array($data)) {
throw new TokenResponseException('Unable to parse response.');
} elseif (isset($data['error'])) {
throw new TokenResponseException("Error occurred: '{$data['error']}'");
}
return $data;
}
/**
* #override to fix since parent implementation from lib not sending the oauth_verifier when requesting access token
* Builds the authorization header for an authenticated API request
*
* #param string $method
* #param UriInterface $uri the uri the request is headed
* #param \OAuth\OAuth1\Token\TokenInterface $token
* #param $bodyParams array
* #return string
*/
protected function buildAuthorizationHeaderForAPIRequest(
$method,
UriInterface $uri,
TokenInterface $token,
$bodyParams = null
) {
$this->signature->setTokenSecret($token->getAccessTokenSecret());
$parameters = $this->getBasicAuthorizationHeaderInfo();
if (isset($parameters['oauth_callback'])) {
unset($parameters['oauth_callback']);
}
$parameters = array_merge($parameters, ['oauth_token' => $token->getAccessToken()]);
$parameters = array_merge($parameters, $bodyParams);
$parameters['oauth_signature'] = $this->signature->getSignature($uri, $parameters, $method);
$authorizationHeader = 'OAuth ';
$delimiter = '';
foreach ($parameters as $key => $value) {
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
$delimiter = ', ';
}
return $authorizationHeader;
}
}
My Question is how do I pass the url from the store that the integration has been set up on back as a variable in here?(I have it stored in my db)
Thanks for taking the time to take a look.
For anyone who might come across this in future after getting the saved data from the table in my db, I added the Url into the call to make the new class on the checklogin.php script in the documentation:
$oAuthClient = new OauthClient($credentials,$magentoBaseUrl);
And then in OauthClient.php, I added the url to the construct and updated the getRequestTokenEndpoint method and the getAcessTokenEndpoint:
public function __construct(
Credentials $credentials,
$magentoBaseUrl = null,
ClientInterface $httpClient = null,
TokenStorageInterface $storage = null,
SignatureInterface $signature = null,
UriInterface $baseApiUri = null
) {
if (!isset($httpClient)) {
$httpClient = new \OAuth\Common\Http\Client\CurlClient();
}
if (!isset($storage)) {
$storage = new \OAuth\Common\Storage\Session();
}
if (!isset($signature)) {
$signature = new \OAuth\OAuth1\Signature\Signature($credentials);
}
if (!isset($magentoBaseUrl)) {
die();
}
$this->magentoBaseUrl = $magentoBaseUrl;
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
}
...
/**
* #return UriInterface
*/
public function getRequestTokenEndpoint()
{
return new Uri($this->magentoBaseUrl.'/oauth/token/request');
}
...
/**
* Returns the access token API endpoint.
*
* #return UriInterface
*/
public function getAccessTokenEndpoint()
{
return new Uri($this->magentoBaseUrl.'/oauth/token/access');
}
I am having an issue with my production env. On my local machine when I run the command I built:
php artisan updateusers:badcustomernumbers
everything runs as expected, no jobs fail.
When I deployed and tried to run this same task I get:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method App\Services\MiddlewareApi::get_lowest_active_customer_number_by_email() in .../app/Jobs/UpdateBadCustomerNumbersJob.php:48
Here is UpdateBadCustomerNumbersJob.php:
<?php
namespace App\Jobs;
use App\AppUser;
use Illuminate\Support\Facades\Log;
use App\Subscription;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Mockery\Exception;
use App\Http\Controllers\UpdateUserController;
use App\Services\MiddlewareApi;
class UpdateBadCustomerNumbersJob extends Job
{
/**
* App users to update customer number for
* #var AppUser
*/
protected $appUsers;
/**
* The number of times the job may be attempted.
*
* #var int
*/
public $tries = 2;
/**
* UpdateBadCustomerNumbersJob constructor.
* #param $appUsers
*/
public function __construct($appUsers)
{
$this->appUsers = $appUsers;
}
/**
* #param UpdateUserController $updateUserController
*/
public function handle(UpdateUserController $updateUserController)
{
$middlewareApi = new MiddlewareApi();
foreach ($this->appUsers as $user) {
$userCustomerNumber = $middlewareApi->get_lowest_active_customer_number_by_email($user->email);
if(!is_null($userCustomerNumber) AND $userCustomerNumber !== false AND !empty($userCustomerNumber->customerNumber)) {
$updateUserController->updateAggregateCustomerNumber($user, $userCustomerNumber, true);
$updateUserController->updateAppDatasCustomerNumber($user, $userCustomerNumber, true);
$updateUserController->updateSubscriptionsCustomerNumber($user, $userCustomerNumber, true);
$updateUserController->updateAppUserCustomerNumber($user, $userCustomerNumber, true);
} else {
//if there is no customer number available just delete this user because they must not have any active subscriptions any longer
$updateUserController->deleteAggregateData($user);
$updateUserController->deleteAppDatas($user);
$updateUserController->deleteSubscriptions($user);
$updateUserController->deleteAppUser($user);
}
}
}
}
and here is MiddlewareAPI.php:
<?php
namespace App\Services;
use Illuminate\Support\Facades\Log;
use Mockery\Exception;
use GuzzleHttp\Client;
class MiddlewareApi
{
/**
* #var $middlewareToken
*/
private $middlewareToken;
/**
* #var $middlewareUrl
*/
private $middlewareUrl;
public function __construct()
{
$this->setMiddlewareToken(env('MIDDLEWARE_TOKEN'));
$this->setMiddlewareUrl(env('MIDDLEWARE_BASE_URL'));
}
/**
* Sets the Middleware API Token
* #param $token
*/
public function setMiddlewareToken( $token )
{
$this->middlewareToken = $token;
}
/**
* Gets the Middleware API Token
* #return mixed
*/
public function getMiddlewareToken()
{
return $this->middlewareToken;
}
/**
* Sets the Middleware base url
* #param $url
*/
public function setMiddlewareUrl( $url )
{
$this->middlewareUrl = $url;
}
/**
* Gets the Middleware base url
* #return mixed
*/
public function getMiddlewareUrl()
{
return $this->middlewareUrl;
}
/**
* Retrieves the Active subscriptions of a customer
* based on customer number
* #param $customerNumber
* #return bool|mixed
*/
public function get_customer_subscriptions_by_customer_number( $customerNumber )
{
$url = $this->getMiddlewareUrl() . 'sub/active/customernumber/' . $customerNumber;
$header = ['Token' => $this->getMiddlewareToken()];
$errorText = 'Error in get_customer_subscriptions_by_customer_number: ';
return $this->_get($url,$header,$errorText);
}
/**
* Retrieves the Active subscriptions and Products of a customer
* #param $customerNumber
* #return bool|mixed
*/
public function get_customer_subscriptions_and_products_by_customer_number( $customerNumber )
{
$url = $this->getMiddlewareUrl() . 'data/customernumber/' . $customerNumber;
$header = ['Token' => $this->getMiddlewareToken()];
$errorText = 'Error in get_customer_subscriptions_by_customer_number: ';
return $this->_get($url,$header,$errorText);
}
/**
* Retrieve the lowest active customer number by email address
* #param $email
* #return bool|mixed
*/
public function get_lowest_active_customer_number_by_email( $email )
{
$url = $this->getMiddlewareUrl() . 'customer/findlowestactivecustomernumber/emailaddress/' . $email;
$header = ['Token' => $this->getMiddlewareToken()];
$errorText = 'Error in get_lowest_active_customer_number_by_email: ';
return $this->_get($url, $header, $errorText);
}
/**
* Get method to make all get calls from middleware
* #param $endpoint
* #param $headers
* #param $errorText
* #return bool|mixed
*/
public function _get($endpoint, $headers, $errorText)
{
$client = new Client();
try {
$response = $client->request('GET', $endpoint,
['headers' => $headers]
);
$responseData = json_decode($response->getBody()->getContents());
return $responseData;
} catch (Exception $e) {
Log::error($errorText. $e);
return false;
}
}
/**
* Returns data with status code in json format
* #param $statusCode
* #param $data
* #return \Illuminate\Http\JsonResponse
*/
public function apiReturnResponseInJson( $statusCode, $data )
{
$content = ['status' => $statusCode, 'data' => $data];
return response()->json($content, $statusCode);
}
}
I tried running composer update and php artisan cache:clear but I am still getting the same error. I even ssh'd in and get_lowest_active_customer_number_by_email method is present in MiddlewareApi.php.
Any ideas what the problem may be?
I have been trying to design a Signup Page using a tutorial in a Zend framework 2 Book .Problem is that I am unable to complete signup after running it as , clicking on register gives a socket error , which I have no clue.
Zend\Http\Client\Adapter\Exception\RuntimeException
File:
C:\xampp\htdocs\ZF2AD\Chapter10\client\vendor\zendframework\zend-http\src\Client\Adapter\Socket.php:256
Message:
Unable to connect to zf2-api:80 . Error #0: stream_socket_client():unable to connect to zf2-api:80 (php_network_getaddresses: getaddrinfo failed: No such host is known. )
I am using Api to connect to database.Below is the code for my Apiclient.php
<?php
namespace Api\Client;
use Zend\Http\Client;
use Zend\Http\Request;
use Zend\Json\Decoder as JsonDecoder;
use Zend\Json\Json;
use Zend\Log\Logger;
use Zend\Log\Writer\Stream;
/**
* This client manages all the operations needed to interface with the
* social network API
*
* #package default
*/
class ApiClient {
/**
* Holds the client we will reuse in this class
*
* #var Client
*/
protected static $client = null;
/**
* Holds the endpoint urls
*
* #var string
*/
protected static $endpointHost = 'http://zf2-api';
protected static $endpointWall = '/api/wall/%s';
protected static $endpointFeeds = '/api/feeds/%s';
protected static $endpointSpecificFeed = '/api/feeds/%s/%d';
protected static $endpointUsers = '/api/users';
protected static $endpointGetUser = '/api/users/%s';
protected static $endpointUserLogin = '/api/users/login';
/**
* Perform an API reqquest to retrieve the data of the wall
* of an specific user on the social network
*
* #param string $username
* #return Zend\Http\Response
*/
public static function getWall($username)
{
$url = self::$endpointHost . sprintf(self::$endpointWall, $username);
return self::doRequest($url);
}
/**
* Perform an API request to post content on the wall of an specific user
*
* #param string $username
* #param array $data
* #return Zend\Http\Response
*/
public static function postWallContent($username, $data)
{
$url = self::$endpointHost . sprintf(self::$endpointWall, $username);
return self::doRequest($url, $data, Request::METHOD_POST);
}
/**
* Perform an API request to get the list subscriptions of a username
*
* #param string $username
* #return Zend\Http\Response
*/
public static function getFeeds($username)
{
$url = self::$endpointHost . sprintf(self::$endpointFeeds, $username);
return self::doRequest($url);
}
/**
* Perform an API request to add a new subscription
*
* #param string $username
* #param array $postData
* #return Zend\Http\Response
*/
public static function addFeedSubscription($username, $postData)
{
$url = self::$endpointHost . sprintf(self::$endpointFeeds, $username);
return self::doRequest($url, $postData, Request::METHOD_POST);
}
/**
* Perform an API request to remove a subscription
*
* #param string $username
* #param array $postData
* #return Zend\Http\Response
*/
public static function removeFeedSubscription($username, $feedId)
{
$url = self::$endpointHost . sprintf(self::$endpointSpecificFeed, $username, $feedId);
return self::doRequest($url, null, Request::METHOD_DELETE);
}
/**
* Perform an API request to add a new user
*
* #param array $postData
* #return Zend\Http\Response
*/
public static function registerUser($postData)
{
$url = self::$endpointHost . self::$endpointUsers;
return self::doRequest($url, $postData, Request::METHOD_POST);
}
/**
* Perform an API request to get the basic data of a user
*
* #param string $username
* #return Zend\Http\Response
*/
public static function getUser($username)
{
$url = self::$endpointHost . sprintf(self::$endpointGetUser, $username);
return self::doRequest($url, null, Request::METHOD_GET);
}
/**
* Perform an API request to authenticate a user
*
* #param array $postData Array containing username and password on their respective keys
* #return Zend\Http\Response
*/
public static function authenticate($postData)
{
$url = self::$endpointHost . self::$endpointUserLogin;
return self::doRequest($url, $postData, Request::METHOD_POST);
}
/**
* Create a new instance of the Client if we don't have it or
* return the one we already have to reuse
*
* #return Client
*/
protected static function getClientInstance()
{
if (self::$client === null) {
self::$client = new Client();
self::$client->setEncType(Client::ENC_URLENCODED);
}
return self::$client;
}
/**
* Perform a request to the API
*
* #param string $url
* #param array $postData
* #param Client $client
* #return Zend\Http\Response
* #author Christopher
*/
protected static function doRequest($url, array $postData = null, $method = Request::METHOD_GET)
{
$client = self::getClientInstance();
$client->setUri($url);
$client->setMethod($method);
if ($postData !== null) {
$client->setParameterPost($postData);
}
$response = $client->send();
if ($response->isSuccess()) {
return JsonDecoder::decode($response->getBody(), Json::TYPE_ARRAY);
} else {
$logger = new Logger;
$logger->addWriter(new Stream('data/logs/apiclient.log'));
$logger->debug($response->getBody());
return FALSE;
}
}
}
Refining the error , I got to know that this is the main error in all errors
stream_socket_client(): php_network_getaddresses: getaddrinfo failed: No such host is known.
I have tried solutions provided in similar questions , but they didnt helped . If anyone knows about it please help.
I'm working with Abraham's twitteroauth to implement Twitter OAuth in my application. While running my application, this is the error I'm encountering:
Fatal error: Class 'Response' not found in /opt/lampp/htdocs/tmhOAuth-master/twitteroauth.php on line 108
Now, this is what my twitteroauth.php file looks like till the 108th line:
<?php
/**
* The most popular PHP library for use with the Twitter OAuth REST API.
*
* #license MIT
*/
//namespace twitteroauthm\src\TwitterOAuth;
//use twitteroauthm\src\TwitterOAuth;
use twitteroauthm\src\Util\JsonDecoder;
require "twitteroauthm/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth as Config;
//require_once("twitteroauthm/src/TwitterOAuth.php");
//use twitteroauthm\src\TwitterOAuth;
//require_once("twitteroauthm/src/Config.php");
/**
* TwitterOAuth class for interacting with the Twitter API.
*
* #author Abraham Williams <abraham#abrah.am>
*/
class TwitterOAuth extends Config
{
const API_VERSION = '1.1';
const API_HOST = 'https://api.twitter.com';
const UPLOAD_HOST = 'https://upload.twitter.com';
/** #var Response details about the result of the last request */
private $response;
/** #var string|null Application bearer token */
private $bearer;
/** #var Consumer Twitter application details */
private $consumer;
/** #var Token|null User access token details */
private $token;
/** #var HmacSha1 OAuth 1 signature type used by Twitter */
private $signatureMethod;
/**
* Constructor
*
* #param string $consumerKey The Application Consumer Key
* #param string $consumerSecret The Application Consumer Secret
* #param string|null $oauthToken The Client Token (optional)
* #param string|null $oauthTokenSecret The Client Token Secret (optional)
*/
public function __construct($consumerKey, $consumerSecret, $oauthToken = null, $oauthTokenSecret = null)
{
$this->resetLastResponse();
$this->signatureMethod = new HmacSha1();
$this->consumer = new Consumer($consumerKey, $consumerSecret);
if (!empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
if (empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->bearer = $oauthTokenSecret;
}
}
/**
* #param string $oauthToken
* #param string $oauthTokenSecret
*/
public function setOauthToken($oauthToken, $oauthTokenSecret)
{
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
/**
* #return string|null
*/
public function getLastApiPath()
{
return $this->response->getApiPath();
}
/**
* #return int
*/
public function getLastHttpCode()
{
return $this->response->getHttpCode();
}
/**
* #return array
*/
public function getLastXHeaders()
{
return $this->response->getXHeaders();
}
/**
* #return array|object|null
*/
public function getLastBody()
{
return $this->response->getBody();
}
/**
* Resets the last response cache.
*/
public function resetLastResponse()
{
$this->response = new Response();
}
What seems to be wrong with my code? Is there a way to include the Response class into my file that I'm not aware of?
I'm also including a few screenshots to give an overview of my project's file structure:
as you are using namespaces, add 'use Response' at the top, as for now your response class is not recognized
same way as you are using Confing, just make sure linke to Response class will be recognized.
use Abraham\TwitterOAuth\TwitterOAuth as Config;
use Abraham\TwitterOAuth\Response as Response;
or try to include it at the top:
require_once('your_path/Response.php');
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
WAMP Stack PHP “Fatal error: Class ‘SoapClient’ not found”
I downloaded a library from this site library and when I tried to use it's examples it says : "Fatal error: Class 'SoapClient' not found in C:\wamp\www\Amazon-ECS\Exeu-Amazon-ECS-PHP-Library-9030053\lib\AmazonECS.class.php on line 231" How should I able to fix this?
<?php
/**
* Amazon ECS Class
* http://www.amazon.com
* =====================
*
* This class fetchs productinformation via the Product Advertising API by Amazon (formerly ECS).
* It supports three basic operations: ItemSearch, ItemLookup and BrowseNodeLookup.
* These operations could be expanded with extra prarmeters to specialize the query.
*
* Requirement is the PHP extension SOAP.
*
* #package AmazonECS
* #license http://www.gnu.org/licenses/gpl.txt GPL
* #version 1.3.4-DEV
* #author Exeu <exeu65#googlemail.com>
* #contributor Julien Chaumond <chaumond#gmail.com>
* #link http://github.com/Exeu/Amazon-ECS-PHP-Library/wiki Wiki
* #link http://github.com/Exeu/Amazon-ECS-PHP-Library Source
*/
class AmazonECS
{
const RETURN_TYPE_ARRAY = 1;
const RETURN_TYPE_OBJECT = 2;
/**
* Baseconfigurationstorage
*
* #var array
*/
private $requestConfig = array(
'requestDelay' => false
);
/**
* Responseconfigurationstorage
*
* #var array
*/
private $responseConfig = array(
'returnType' => self::RETURN_TYPE_OBJECT,
'responseGroup' => 'Small',
'optionalParameters' => array()
);
/**
* All possible locations
*
* #var array
*/
private $possibleLocations = array('de', 'com', 'co.uk', 'ca', 'fr', 'co.jp', 'it', 'cn', 'es');
/**
* The WSDL File
*
* #var string
*/
protected $webserviceWsdl = 'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl';
/**
* The SOAP Endpoint
*
* #var string
*/
protected $webserviceEndpoint = 'https://webservices.amazon.%%COUNTRY%%/onca/soap?Service=AWSECommerceService';
/**
* #param string $accessKey
* #param string $secretKey
* #param string $country
* #param string $associateTag
*/
public function __construct($accessKey, $secretKey, $country, $associateTag)
{
if (empty($accessKey) || empty($secretKey))
{
throw new Exception('No Access Key or Secret Key has been set');
}
$this->requestConfig['accessKey'] = $accessKey;
$this->requestConfig['secretKey'] = $secretKey;
$this->associateTag($associateTag);
$this->country($country);
}
/**
* execute search
*
* #param string $pattern
*
* #return array|object return type depends on setting
*
* #see returnType()
*/
public function search($pattern, $nodeId = null)
{
if (false === isset($this->requestConfig['category']))
{
throw new Exception('No Category given: Please set it up before');
}
$browseNode = array();
if (null !== $nodeId && true === $this->validateNodeId($nodeId))
{
$browseNode = array('BrowseNode' => $nodeId);
}
$params = $this->buildRequestParams('ItemSearch', array_merge(
array(
'Keywords' => $pattern,
'SearchIndex' => $this->requestConfig['category']
),
$browseNode
));
return $this->returnData(
$this->performSoapRequest("ItemSearch", $params)
);
}
/**
* execute ItemLookup request
*
* #param string $asin
*
* #return array|object return type depends on setting
*
* #see returnType()
*/
public function lookup($asin)
{
$params = $this->buildRequestParams('ItemLookup', array(
'ItemId' => $asin,
));
return $this->returnData(
$this->performSoapRequest("ItemLookup", $params)
);
}
/**
* Implementation of BrowseNodeLookup
* This allows to fetch information about nodes (children anchestors, etc.)
*
* #param integer $nodeId
*/
public function browseNodeLookup($nodeId)
{
$this->validateNodeId($nodeId);
$params = $this->buildRequestParams('BrowseNodeLookup', array(
'BrowseNodeId' => $nodeId
));
return $this->returnData(
$this->performSoapRequest("BrowseNodeLookup", $params)
);
}
/**
* Implementation of SimilarityLookup
* This allows to fetch information about product related to the parameter product
*
* #param string $asin
*/
public function similarityLookup($asin)
{
$params = $this->buildRequestParams('SimilarityLookup', array(
'ItemId' => $asin
));
return $this->returnData(
$this->performSoapRequest("SimilarityLookup", $params)
);
}
/**
* Builds the request parameters
*
* #param string $function
* #param array $params
*
* #return array
*/
protected function buildRequestParams($function, array $params)
{
$associateTag = array();
if(false === empty($this->requestConfig['associateTag']))
{
$associateTag = array('AssociateTag' => $this->requestConfig['associateTag']);
}
return array_merge(
$associateTag,
array(
'AWSAccessKeyId' => $this->requestConfig['accessKey'],
'Request' => array_merge(
array('Operation' => $function),
$params,
$this->responseConfig['optionalParameters'],
array('ResponseGroup' => $this->prepareResponseGroup())
)));
}
/**
* Prepares the responsegroups and returns them as array
*
* #return array|prepared responsegroups
*/
protected function prepareResponseGroup()
{
if (false === strstr($this->responseConfig['responseGroup'], ','))
return $this->responseConfig['responseGroup'];
return explode(',', $this->responseConfig['responseGroup']);
}
/**
* #param string $function Name of the function which should be called
* #param array $params Requestparameters 'ParameterName' => 'ParameterValue'
*
* #return array The response as an array with stdClass objects
*/
protected function performSoapRequest($function, $params)
{
if (true === $this->requestConfig['requestDelay']) {
sleep(1);
}
$soapClient = new SoapClient(
$this->webserviceWsdl,
array('exceptions' => 1)
);
$soapClient->__setLocation(str_replace(
'%%COUNTRY%%',
$this->responseConfig['country'],
$this->webserviceEndpoint
));
$soapClient->__setSoapHeaders($this->buildSoapHeader($function));
return $soapClient->__soapCall($function, array($params));
}
/**
* Provides some necessary soap headers
*
* #param string $function
*
* #return array Each element is a concrete SoapHeader object
*/
protected function buildSoapHeader($function)
{
$timeStamp = $this->getTimestamp();
$signature = $this->buildSignature($function . $timeStamp);
return array(
new SoapHeader(
'http://security.amazonaws.com/doc/2007-01-01/',
'AWSAccessKeyId',
$this->requestConfig['accessKey']
),
new SoapHeader(
'http://security.amazonaws.com/doc/2007-01-01/',
'Timestamp',
$timeStamp
),
new SoapHeader(
'http://security.amazonaws.com/doc/2007-01-01/',
'Signature',
$signature
)
);
}
/**
* provides current gm date
*
* primary needed for the signature
*
* #return string
*/
final protected function getTimestamp()
{
return gmdate("Y-m-d\TH:i:s\Z");
}
/**
* provides the signature
*
* #return string
*/
final protected function buildSignature($request)
{
return base64_encode(hash_hmac("sha256", $request, $this->requestConfig['secretKey'], true));
}
/**
* Basic validation of the nodeId
*
* #param integer $nodeId
*
* #return boolean
*/
final protected function validateNodeId($nodeId)
{
if (false === is_numeric($nodeId) || $nodeId <= 0)
{
throw new InvalidArgumentException(sprintf('Node has to be a positive Integer.'));
}
return true;
}
/**
* Returns the response either as Array or Array/Object
*
* #param object $object
*
* #return mixed
*/
protected function returnData($object)
{
switch ($this->responseConfig['returnType'])
{
case self::RETURN_TYPE_OBJECT:
return $object;
break;
case self::RETURN_TYPE_ARRAY:
return $this->objectToArray($object);
break;
default:
throw new InvalidArgumentException(sprintf(
"Unknwon return type %s", $this->responseConfig['returnType']
));
break;
}
}
/**
* Transforms the responseobject to an array
*
* #param object $object
*
* #return array An arrayrepresentation of the given object
*/
protected function objectToArray($object)
{
$out = array();
foreach ($object as $key => $value)
{
switch (true)
{
case is_object($value):
$out[$key] = $this->objectToArray($value);
break;
case is_array($value):
$out[$key] = $this->objectToArray($value);
break;
default:
$out[$key] = $value;
break;
}
}
return $out;
}
/**
* set or get optional parameters
*
* if the argument params is null it will reutrn the current parameters,
* otherwise it will set the params and return itself.
*
* #param array $params the optional parameters
*
* #return array|AmazonECS depends on params argument
*/
public function optionalParameters($params = null)
{
if (null === $params)
{
return $this->responseConfig['optionalParameters'];
}
if (false === is_array($params))
{
throw new InvalidArgumentException(sprintf(
"%s is no valid parameter: Use an array with Key => Value Pairs", $params
));
}
$this->responseConfig['optionalParameters'] = $params;
return $this;
}
/**
* Set or get the country
*
* if the country argument is null it will return the current
* country, otherwise it will set the country and return itself.
*
* #param string|null $country
*
* #return string|AmazonECS depends on country argument
*/
public function country($country = null)
{
if (null === $country)
{
return $this->responseConfig['country'];
}
if (false === in_array(strtolower($country), $this->possibleLocations))
{
throw new InvalidArgumentException(sprintf(
"Invalid Country-Code: %s! Possible Country-Codes: %s",
$country,
implode(', ', $this->possibleLocations)
));
}
$this->responseConfig['country'] = strtolower($country);
return $this;
}
/**
* Setting/Getting the amazon category
*
* #param string $category
*
* #return string|AmazonECS depends on category argument
*/
public function category($category = null)
{
if (null === $category)
{
return isset($this->requestConfig['category']) ? $this->requestConfig['category'] : null;
}
$this->requestConfig['category'] = $category;
return $this;
}
/**
* Setting/Getting the responsegroup
*
* #param string $responseGroup Comma separated groups
*
* #return string|AmazonECS depends on responseGroup argument
*/
public function responseGroup($responseGroup = null)
{
if (null === $responseGroup)
{
return $this->responseConfig['responseGroup'];
}
$this->responseConfig['responseGroup'] = $responseGroup;
return $this;
}
/**
* Setting/Getting the returntype
* It can be an object or an array
*
* #param integer $type Use the constants RETURN_TYPE_ARRAY or RETURN_TYPE_OBJECT
*
* #return integer|AmazonECS depends on type argument
*/
public function returnType($type = null)
{
if (null === $type)
{
return $this->responseConfig['returnType'];
}
$this->responseConfig['returnType'] = $type;
return $this;
}
/**
* Setter/Getter of the AssociateTag.
* This could be used for late bindings of this attribute
*
* #param string $associateTag
*
* #return string|AmazonECS depends on associateTag argument
*/
public function associateTag($associateTag = null)
{
if (null === $associateTag)
{
return $this->requestConfig['associateTag'];
}
$this->requestConfig['associateTag'] = $associateTag;
return $this;
}
/**
* #deprecated use returnType() instead
*/
public function setReturnType($type)
{
return $this->returnType($type);
}
/**
* Setting the resultpage to a specified value.
* Allows to browse resultsets which have more than one page.
*
* #param integer $page
*
* #return AmazonECS
*/
public function page($page)
{
if (false === is_numeric($page) || $page <= 0)
{
throw new InvalidArgumentException(sprintf(
'%s is an invalid page value. It has to be numeric and positive',
$page
));
}
$this->responseConfig['optionalParameters'] = array_merge(
$this->responseConfig['optionalParameters'],
array("ItemPage" => $page)
);
return $this;
}
/**
* Enables or disables the request delay.
* If it is enabled (true) every request is delayed one second to get rid of the api request limit.
*
* Reasons for this you can read on this site:
* https://affiliate-program.amazon.com/gp/advertising/api/detail/faq.html
*
* By default the requestdelay is disabled
*
* #param boolean $enable true = enabled, false = disabled
*
* #return boolean|AmazonECS depends on enable argument
*/
public function requestDelay($enable = null)
{
if (false === is_null($enable) && true === is_bool($enable))
{
$this->requestConfig['requestDelay'] = $enable;
return $this;
}
return $this->requestConfig['requestDelay'];
}
}
The error appears to be caused by the version of PHP that you have does not have the SOAP extension enabled.
To resolve this simply start wamp, click on the wamp system tray icon. Within this screen select PHP then PHP extensions. This will display a list of extensions. Ensure that php_soap is ticked.
If you intend to access soap servers that use HTTPs then you will also ensure php_openssl is ticked.