I suspect the finer mechanics of this question are wider than just the specific class library I'm looking to use, in this instance it's the use case I'm struggling with.
I'm looking at implementing the DMS Meetup API for PHP ( https://github.com/rdohms/meetup-api-client ) yet having installed the codebase and project dependencies I'm getting the error
Fatal error: Class 'MeetupOAuthClient' not found in...
The basic structure I have is
require('vendor/autoload.php');
// OAuth Authentication
$config = array(
'consumer_key' => '*****',
'consumer_secret' => '*****',
'token' => '*****',
'token_secret' => '*****',
);
$client = MeetupOAuthClient::factory($config);
It's suggesting the library isn't being loaded - but my understanding is the autoload.php should handle this no?
The DMS library uses namespaces, and you need to tell the autoloader where to find it in those namespaces.
After your require line, add the following and things should work:
use DMS\Service\Meetup\MeetupOAuthClient;
You could also change the last line to the following and get a similar effect:
$client = DMS\Service\Meetup\MeetupOAuthClient::factory($config);
Related
I'm attempting to make a PHP-application that generates Facebook ad reports for a company, using the Facebook PHP Ads SDK. I'm following the Marketing API QuickStart that essentially generates code for you. I have all access I need to reach the company's ad account ID.
(I'm not showing the token- and ID-variables, unless absolutely necessary. If so, tell me).
require __DIR__ . '/vendor/autoload.php';
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\AdsInsights;
use FacebookAds\Api;
use FacebookAds\Logger\CurlLogger;
$access_token;
$ad_account_id;
$app_secret;
$app_id;
$api = Api::init($app_id, $app_secret, $access_token);
$api->setLogger(new CurlLogger());
$fields = array(
'frequency',
'actions:link_click',
'call_to_action_clicks',
'actions:tab_view',
);
$params = array(
'level' => 'adset',
'filtering' => array(array('field' => 'delivery_info','operator' => 'IN','value' => array('inactive','active','limited','archived','permanently_deleted','completed','recently_completed','not_delivering','not_published','rejected','recently_rejected','rejected','pending_review','scheduled'))),
'breakdowns' => array('place_page_id'),
'time_range' => array('since' => '2017-09-20','until' => '2017-10-20'),
);
echo json_encode((new AdAccount($ad_account_id))->getInsights(
$fields,
$params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);
However, when running the code I get the error message:
Fatal error: Uncaught exception
'FacebookAds\Http\Exception\AuthorizationException' with message
'(#100) Filtering field delivery_info is invalid.
I try switching around in $fields and $params with parameters found in the documentation, but it switches the blame on other ones as I do, even claiming that some of them don't even exist as alternatives.
I've checked several times in the documentation, it should work.
Does the problem lie elsewhere, is it the wrong kind of ad account ID?
Any help would be very much appreciated.
Try adset.delivery_info instead of just delivery_info. That should work. I learned the hard way, seems like you need to append the object level separated by period for filtering options.
Im using the Zip method with aws-sdk-php and I get an error with my php app when calling ec2client factory object (or the preceding Use clauses, Im not sure...)
require LIBS_PATH . 'aws-sdk-php/aws-autoloader.php';
use Aws\Common\Aws;
use Aws\Common\Enum\Region;
use Aws\Ec2\Ec2Client;
public function createAWSApp($app_id)
{
// Get users region
$this->app->aws_region = $this->getUserAWSRegion();
// Setup the EC2 object
$this->ec2client = Ec2Client::factory(array(
//'profile' => '<profile in your aws credentials file>',
'key' => AWS_ACCESS_KEY_ID,
'secret' => AWS_SECRET_ACCESS_KEY,
'region' => $this->app->aws_region
));
...
The app's framework results in error
The file Aws\Ec2\Ec2Client.php is missing in the libs folder.
If I remove the Use clauses and explicitly name the files such as with a require_once :
require LIBS_PATH . 'aws-sdk-php/aws-autoloader.php';
use Aws\Common\Aws;
use Aws\Common\Enum\Region;
//use Aws\Ec2\Ec2Client;
require_once LIBS_PATH . 'aws-sdk-php/Aws/Ec2/Ec2client.php';
public function cr...
I get a similar message but looks like PHP default cannot find file error:
Warning: require_once(libs/aws-sdk-php/Aws/Ec2/Ec2client.php): failed to open stream: No such file or directory
LIBS_PATH is correct and works for other libraries Im using, the aws-sdk-php files are definitely present etc.
Please help...
I would like to use the Amazon AWS SDK for PHP in my Yii project, however I get all kinds of include errors (such as include(CFCredentials.php): failed to open stream: No such file or directory ).
I think it may be related to Yii's assumption that class names must match file names...
What can we do??
I've made that:
spl_autoload_unregister(array('YiiBase', 'autoload'));
require_once PATH_TO_AWS_SDK . 'sdk.class.php';
// I write down in PATH_TO_AWS_SDK.'config.inc.php' my CFCredentials
spl_autoload_register(array('YiiBase', 'autoload'));
$amazon_opts = array(
'curlopts' => array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_FORBID_REUSE => false,
),
);
$amazon = new AmazonSES();
$response = $amazon->get_send_quota($amazon_opts);
This worked beautifully:
// Include the SDK
Yii::import('application.vendors.aws.*');
spl_autoload_unregister(array('YiiBase', 'autoload'));
require_once 'sdk.class.php';
spl_autoload_register(array('YiiBase', 'autoload'));
// Instantiate the AmazonEC2 class
$ec2 = new AmazonEC2();
In case someone stumbles upon this issue, I've found that if one is using the PHAR file directly (poor decision, I know) and importing via require_once, you cannot call spl_autoload_register to re-add YiiBase autoload until after your SDK call is complete.
At least this was our case when using the StsClient to call assume role with an IAM role.
This is more easier way, You can use Yii S3 Upload extension.
http://www.yiiframework.com/extension/s3upload/
I'm going to implement login functionality using zend framework 2.
My code as follows.
$dbAdapter = new DbAdapter(array(
'driver' => 'Mysqli',
'database' => 'db',
'username' => 'root',
'password' => 'password'
));
$authAdapter = new AuthAdapter($dbAdapter);
$authAdapter
->setTableName('admin_users')
->setIdentityColumn('user_name')
->setCredentialColumn('password')
;
$authAdapter
->setIdentity($username)
->setCredential($password)
;
$result = $authAdapter->authenticate();
It gives error message as follows.
The supplied parameters to DbTable failed to produce a valid sql statement, please check table and column names for validity.
I checked database configurations and column names. But they are correct. Can anyone give me a clue to check this out please.
Thanks.
There's no need to re-invent the wheel and struggle with this yourself. ZF2 has been created with modularity in mind so that plug in modules for this kind of thing can be written.
There are a few such modules available already at the ZF-Commons site. The one you are looking for is ZfcUser. Just follow the instructions to install and use it. There is even an excellent tutorial written by the author of the module that will take you through the whole process step by step. http://blog.evan.pro/getting-started-with-the-zf2-skeleton-and-zfcuser
There is also an excellent how-to page to tell you how to modify it for your own use.
Alright, I'm tired of racking my brain on this, so hopefully someone here can enlighten me:
I'm trying to access a SOAP service using PHP and nuSOAP. While I have successfully accessed the service using PHP5's built-in SoapClient, I am unfortunately limited to PHP4, and using nuSOAP; resulting in a WSDL error that I can't figure out.
The PHP5 code (works):
$wsdl= 'https://mybilling.hipointinc.com:8443/wsdl.fcgi?get=Session.xsd';
$soap_client = new SoapClient($wsdl, array('trace'=>1));
$args = array("login" => $account_id, "password" => $password, "domain" => $domain);
$session = $soap_client->login($args);
The nuSOAP code (doesn't work):
$wsdl= 'https://mybilling.hipointinc.com:8443/wsdl.fcgi?get=Session.xsd';
$namespace = 'https://mybilling.hipointinc.com/UM/SOAP/Session';
$soap_client = new soapclient($wsdl, true, null, $namespace);
$args = array("login" => $account_id, "password" => $password, "domain" => $domain);
$session = $soap_client->call('login', array($args));
This returns the following error:
wsdl error: http://schemas.portaone.com/soap:LoginRequest (LoginRequest) is not a supported type.
Why does the PHP5 version work, while the nuSOAP version doesn't? I'm sure it just something stupid I've overlooked, but I would appreciate some help.
For more info, I'm using the Porta Switch, PortaBilling XML API: documentation
Ok, after exploring this some more, I finally came to the answer: I had to upgrade the version of the nuSOAP library I was using. Turns out I had an older version, and simply updating that version resolved the problem (Sigh) I knew it was something stupid, but for any of you future coders who happen upon this thread via google: Learn from my mistake, and make sure the resources you are using are up-to-date.