I'm trying to connect to our cloud account, but I get the following error:
Fatal error: Uncaught Error: Class 'ActiveCollab\SDK\Authenticator\Cloud' not found in /www/htdocs/asdf/asdf.org/example-cloud.php:13 Stack trace: #0 {main} thrown in /www/htdocs/asf/asdf.org/example-cloud.php on line 13
require_once('https://app.activecollab.com/xxxxxx/autoload.php');
// Provide name of your company, name of the app that you are developing, your email address and password.
$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud('xxx', 'My Awesome Application', 'vvv#ghf.de', '123qwe123*');
// Show all Active Collab 5 and up account that this user has access to.
print_r($authenticator->getAccounts());
// Show user details (first name, last name and avatar URL).
print_r($authenticator->getUser());
// Issue a token for account #123456789.
$token = $authenticator->issueToken('123456789');
// Did we get it?
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
print $token->getUrl() . "\n";
print $token->getToken() . "\n";
} else {
print "Invalid response\n";
die();
}
What did I wrong?
First line in your code example is not good. You should check the article on basic usage of Composer prior to continuing: https://getcomposer.org/doc/01-basic-usage.md
Once you have properly set up Composer in your development environment, required ActiveCollab SDK, and updated dependencies, your first line will most probably look like this:
require __DIR__ . '/vendor/autoload.php';
But you said:
Installation
If you choose to install this application with Composer instead of pulling down the git repository you will need to add a composer.json file to the location you would like to pull the repository down to featuring:
So I tried to pull down the repository s- or am I wrong ...
https://github.com/activecollab/activecollab-feather-sdk
Related
I am trying to connect to a service bus queue in Microsoft Azure using PHP, using the following code found on the Azure guide:
<?php
require_once 'vendor/autoload.php';
use MicrosoftAzure\Storage\Queue\QueueRestProxy;
use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;
use MicrosoftAzure\Storage\Queue\Models\CreateMessageOptions;
$connectionString = "DefaultEndpointsProtocol=https;AccountName="name";AccountKey=key";
// Create queue REST proxy.
$queueClient = QueueRestProxy::createQueueService($connectionString);
try{
// Create message.
$builder = new ServicesBuilder();
$queueClient->createMessage("cmps297r1", "Hello World!");
}
catch(ServiceException $e){
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/library/azure/dd179446.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
?>
However, when I run it, I get this error:
Catchable fatal error: Argument 4 passed to MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::__construct() must be an instance of MicrosoftAzure\Storage\Common\Internal\Serialization\ISerializer, array given, called in /Applications/XAMPP/xamppfiles/htdocs/297R/vendor/microsoft/azure-storage/src/Queue/QueueRestProxy.php on line 110 and defined in /Applications/XAMPP/xamppfiles/htdocs/297R/vendor/microsoft/azure-storage/src/Common/Internal/ServiceRestProxy.php on line 77
The code you pasted looks fine to me (except that you didn't include use statement for ServicesBuilder class which would cause an "Class not found" error).
And as #Thuan Ng mentioned the code above belongs to Azure Storage Queue, not Service Bus Queue. You need to refer to this documentation How to use Service Bus queues with PHP if you are using Azure Service Bus.
I Know this is an old Post but you are trying to create a storage queue and not a service bus queue
I am new to Facebook Application development.
At a point in my App, I want to revoke the permission that my App have on the user's profile.
At this time
I want to Run a code that will take back all the set permissions for the App on the user's profile.
I have searched the web and I found:
https://developers.facebook.com/docs/facebook-login/permissions/requesting-and-revoking
I want to see some working code to revoke all the permissions that my App has on this user's profile.
What is the delete endpoint and how do I call it ?
I have tried to do this:
$response = $fb->delete("/permissions", $_SESSION['fb_access_token']);
But this does not work, it gives me the folloowing error:
"
Fatal error: Uncaught TypeError: Argument 2 passed to Facebook\Facebook::delete() must be of the type array,
string given, called in /index.php on line 454 and defined in Facebook/Facebook.php:383
Stack trace: #0 /index.php(454): Facebook\Facebook->delete('/permissions', 'ahkadhkdhkdahkadhs...')
#1 index.php(102): step2_sub_step3(Object(Facebook\Facebook)) #2 {main} thrown in Facebook/Facebook.php on line 383
"
According to the documentation, the actual endpoint is
DELETE /{user-id}/permissions
And, the method signature is
public function delete($endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null);
So your code would look more like this:
$response = $fb1->delete("/" . $userID . "/permissions", [], $_SESSION['fb_access_token']);
Notice that you need to get the user's ID first. Or, if the user is already logged in, you can use
$response = $fb1->delete("/me/permissions", [], $_SESSION['fb_access_token']);
I'm trying to implement Mailgun API serive for handle my emails, this is my code according to the documentation:
index.php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
$mgClient = Mailgun::create("key-xxxxxxxxxxxxxxxxxxxxxxxxxxx");
$domain = "xxxxxxx.com";
$mgClient->sendMessage($domain,
array('from' => 'Dwight Schrute<dwight#xxxxxxx.com>',
'to' => 'Michael Scott <xxxx#xxxxx.com>',
'subject' => 'The Printer Caught Fire',
'text' => 'We have a problem.'));
var_dump($result);
composer.json
"require": {
"mailgun/mailgun-php": "^2.3",
"php-http/curl-client": "^1.7",
"guzzlehttp/psr7": "^1.4"
}
everything works fine but $result contains tons of data instead of simple return array with id and message "message was queued thank you". Another problem is when I simulate error to see what happen, unfortunately Mailgun make fatal error instead of connection exception which I can handle:
[30-Nov-2017 10:05:44 UTC] PHP Fatal error: Uncaught exception 'Mailgun\Connection\Exceptions\MissingRequiredParameters' with message 'The parameters passed to the API were invalid. Check your inputs! Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings.' in /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php:254
Stack trace:
#0 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(110): Mailgun\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response))
#1 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(179): Mailgun\Connection\RestClient->send('POST', 'xxxxx.com...', Array, Array)
#2 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(204): Mailgun\Connection\RestClient->post('xxxxx.com...', Array, Array)
#3 /home/xxx/xxx/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(135): Mailgun\Mailgun->post(' in /home/xxxxxx/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php on line 254
I'm using PHP 7 os linux no framework. What I'm doing wrong? Thanks for any advice.
This error occurs whenever utilizing either a sandbox domain or a free account without inviting users called Authorized Recipients. Free plans are intended for test usage and all custom domains require Authorized Recipients. With upgraded plans, custom domains no longer require Authorized Recipients.
Please take a look at the following Help Center article for more information about the Authorized Recipient process:
https://help.mailgun.com/hc/en-us/articles/217531258-Authorized-Recipients
For more information on upgrading, please review:
https://help.mailgun.com/hc/en-us/articles/203599840-How-do-I-upgrade-my-account-
Disclaimer I work at Mailgun
I am new to PHP. When I tried to run the below code getting the following error.
Error Message:
PHP Fatal error: Uncaught Error: Class 'Api' not found in C:\Users\cpa\Downloads\b\vendor\php1.php:4
Stack trace:
#0 {main}
thrown in C:\Users\cpa\Downloads\b\vendor\php1.php on line 4
Api.php is there in the following location. I tried n different ways to include the class but no luck. Please let me know how to resolve this error message.
C:\Users\cpa\Downloads\b\vendor\brightlocal\api\src\BrightLocal
Code:
<?php
require 'vendor/brightlocal/api/src/BrightLocal/Api.php';
$api = new Api('key', 'secret_key');
// get a list of clients
print_r($api->call('/v2/clients/get-all'));
// get a client
print_r($api->call('/v2/clients/get', array(
'client-id' => 1059
)));
// get LSRC report list
print_r($api->call('/v2/lsrc/get-all'));
// get LSRC report
print_r($api->call('/v2/lsrc/get', array(
'campaign-id' => 50
)));
// get CT report list
print_r($api->call('/v2/ct/get-all'));
// get a CT report
print_r($api->call('/v2/ct/get', array(
'report-id' => 259
)));
There are several things that are a bit off:
Why are you in the vendor folder? This things is actually used for external libraries that you download via composer or where you place the autoloader.
The require (why not require_once ?) is in the wrong folder. As can be seen from the error message. My suggestion is that you move the frontcontroller (php1.php) out of the vendor folder and in the folder which has the vendor folder as a subfolder: C:\Users\cpa\Downloads\b and setup your system from there anew.
require 'vendor/brightlocal/api/src/BrightLocal/Api.php';
I'm new to Propel and I need to work with a website that was already setup with Propel (1.6.9).
I got this working on my laptop and generated without any errors. (Yay!)
After generating classes (on the same schema.xml and other related files as earlier on) there seem to be some differences. (spotted in file sizes) When I uploaded these files to the web hosting where the old files were doing a fine job, I ran into an error:
Fatal error: Uncaught exception 'PropelException' with message 'Unknown parser class "PropelArrayParser"' in /var/www/vhosts/10/154462/webspace/httpdocs/DOMAIN/vendor/propel/propel1/runtime/lib/parser/PropelParser.php:101
Stack trace:
#0 /var/www/vhosts/10/154462/webspace/httpdocs/DOMAIN/vendor/propel/propel1/runtime/lib/om/BaseObject.php(375): PropelParser::getParser('Array')
#1 /var/www/vhosts/10/154462/webspace/httpdocs/DOMAIN/vendor/propel/propel1/runtime/lib/om/BaseObject.php(424): BaseObject->exportTo('Array', 'fieldName')
#2 /var/www/vhosts/10/154462/webspace/httpdocs/DOMAIN/src/controllers/UsersController.php(26): BaseObject->__call('toArray', Array)
#3 /var/www/vhosts/10/154462/webspace/httpdocs/DOMAIN/src/controllers/UsersController.php(26): User->toArray('fieldName')
#4 /var/www/vhosts/10/154462/webspace/httpdocs/DOMAIN/framework/framework.php(196): require('/var/www/vhosts...')
#5 /var/www/vhosts/10/154462/web in /var/www/vhosts/10/154462/webspace/httpdocs/DOMAIN/vendor/propel/propel1/runtime/lib/parser/PropelParser.php on line 101
The error is referring to:
$case = new AgencyCosts();
$case->fromArray($_POST, BasePeer::TYPE_FIELDNAME);
$case->save();
So I figured something was wrong with includes. That's why I added the following to my init.php:
set_include_path(dirname(DIR) . '/vendor/propel/propel1/runtime/lib/parser' . PATH_SEPARATOR . get_include_path());
require dirname(DIR) . '/vendor/propel/propel1/runtime/lib/parser/PropelJSONParser.php';
Without any success.
The init.php (where the including is done) is available here.
Any help would be appreciated.
You're getting this exception when Propel cannot find the class definition. From Propel's code:
// PropelParse::getParser
if (!class_exists($class)) {
throw new PropelException(sprintf('Unknown parser class "%s"', $class));
}
Propel generates a classmap file, where the paths of all Propel's classes are written. It seems like you just get the wrong file included or wrong paths in it. Take a look at your configuration file for the classmap key:
$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-<you-project-name>-conf.php');
And then examine the contents of that file. It might happen because you blindly moved the files from your computer to the server.