Class 'Asana' not found in Laravel Asana - php

I am developing a timetracker web application and I want to sync my Asana tasks (https://app.asana.com/ ) into webpage. I am Using laravel restful service for this. I've successfully installed the Laravel-Asana package ( https://github.com/Torann/laravel-asana). But Now getting error with getProjects() method.
I configured the Asana API Key & Asana default workspace in \vendor\torann\laravel-asana\src\config\config.php
Error is Class 'Asana' not found
Code : .
protected static $restful = true;
public function task()
{
Asana::getProjects();
echo "task Fetched";
}
}
?>
Anyone please help me. thanks

I think they are missing some important points in package documentation.
If you are using the class Asana it should be loaded in to the project.
So go to your app file app/config/app.php and add one new item in the providers array by adding comma at the end:
'Torann\LaravelAsana\ServiceProvider'

Related

How to setup OMISE PHP SDK to Laravel framework

I'm starting to learn Omise Payment Getway. On Omise documentation have information about PHP SDK. I'm using Laravel Framework on it. However, i'm struggling to implement the Omise PHP SDK into my Laravel site..
I have 2 question when setup the Omise PHP SDK :
The integration - after i install Omise by composer. i don't know how to use it. first, i want to display my Omise balance. here is my code on controller
use Omise\OmiseBalance;
class OmiseController extends Controller
{
public function index()
{
$balance = OmiseBalance::retrieve();
dd($balance);
}
}
but display error
Class "Omise\OmiseBalance" not found
i tried other way, but still not work..
Place the Secret and Public Key - where should i put the Secret key and Public Key on my Laravel. and how to fetch the keys?
Currently i just put this keys into my file .env
OMISE_PUBLIC_KEY=pkey_test_xxx
OMISE_SECRET_KEY=skey_test_xxx
OMISE_API_VERSION=2019-05-29
What is the correct way for me to integrate Omise PHP SDK into my Laravel Site. please help.

Laravel Socialite Implement stateless for Twitter

I would like to implement stateless method to Twitter but it seems that it is not available for TwitterProvider class as it returns
Call to undefined method Laravel\Socialite\One\TwitterProvider::stateless()
Here is my redirectToProvider method currently.
public function redirectToProvider($socialMedia)
{
$provider = strtolower($socialMedia);
return Socialite::driver($provider)->stateless()->redirect();
throw new NotFoundHttpException;
}
What is the correct implementation or what do I miss?
As mentioned by #driesvints from this question #415 I've opened at the Laravel Socialite repository, stateless is unavailable for Twitter since it uses OAuth 1.0.
They already pushed a PR #5661 to update also the Laravel Docs mentioning this specification. Click the link to see the update. Staless Authentication
I would update this answer if whatever my solution would be.

Integrate ZOHO API with Laravel 5.7

I tried to integrate Laravel application with ZOHO SDK but it's not working, zohocrm/php-sdk is for PHP not for Laravel. I have tried third parties packages but none is working.
Zoho API Version: 2.0
Laravel Version: 5.7
I have tried these packages also
https://packagist.org/packages/atlasresults/zoho-laravel-crm-php
https://github.com/rahulreghunath/Zoho
The issue with Official SDK is it could not find the class ZCRMRestClient when generating grant-token.
https://www.zoho.com/crm/help/developer/server-side-sdks/php.html
public function abc()
{
ZCRMRestClient::initialize();
$oAuthClient = ZohoOAuth::getClientInstance();
$grantToken = “paste_the_self_authorized_grant_token_here”;
$oAuthTokens = $oAuthClient->generateAccessToken($grantToken);
}
Any help would be appreciated.
When using Zoho CRM SDK with Laravel, all the class all registered in the global namespace. Just add a "\" before the class name as follows:
public function abc()
{
\ZCRMRestClient::initialize();
$oAuthClient = \ZohoOAuth::getClientInstance();
$grantToken = “paste_the_self_authorized_grant_token_here”;
$oAuthTokens = $oAuthClient->generateAccessToken($grantToken);
}

CAS Authentication with Yii Framework

I'm facing some troubles trying to implement CAS Authentication with Yii framework. I downloaded the client classes and everything is working when I'm not using any framework, but when I try to integrate with Yii validation seems to not be working at all.
Can Anyone please describe the process to successfuly make a CAS validation with yii.
I put the clients files under /myapp/protected/vendor directory, then I put the following lines at the begining of the controller
Yii::import('application.vendors.*');
require_once('CAS/CAS.php');
Then I created the method for use my CAS Classes
public function casValidation()
{
phpCAS::client(CAS_VERSION_2_0, $server, $port, "/cas",false);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
if(isset($_REQUEST['logout']))
{
phpCAS::logout();
}
}
And Finally I try to validate from my index action
public function actionIndex()
{
$this->casValidation();
$this->render('index');
}
But in the web browser shows the following error
PHP warning
include(CAS_Client.php) [function.include]: failed to open >stream: No such file or directory
C:\app\vertrigo\Vertrigophp52\www\testyii\framework\YiiBase.php(427)
Am I Missing something? What should I do to make things work?
Finally I got it working, turns out that I had made a couple of mistakes.
First of all I should not have been using require statement. The reason for this is that Yii alredy take care of loading the classes via the import method as shown below.
Yii::import('application.vendor.CAS.*')
Second thing I had a typo on this import, I had
/* This is wrong */
Yii::import('application.vendors.CAS.*')
instead of
/* This is correct */
Yii::import('application.vendor.CAS.*')
So Yii was looking for the vendors directory which does not exist.
And finally, to successfully use the import method the file containing your class has to have the same name. So if you have a class name user you have to name your file user.php in order to Yii can load it successfully.

CodeIgniter - Why does library load fine in view but not in controller

I'm using Stripe's php library. DL link: https://code.stripe.com/stripe-php-latest.zip
I've included the library like so inside of a view:
require_once(APPPATH.'libraries/stripe/lib/stripe.php');
Everything works fine when I do this in a view, but if I attempt to do it in a controller I get a server error. Why?
I have tried codeigniters load library method, but still a server error. I've change all capitals to lowercases, still the error.
Loading Packages:
$this->load->add_package_path(APPPATH.'third_party/stripe/');
$this->load->library('stripe');
Documentation: Application "Packages" section
http://ellislab.com/codeigniter/user-guide/libraries/loader.html
If you use third_party libraries, like for example the Facebook PHP SDK, use the following code:
$this->_obj->load->add_package_path(APPPATH.'third_party/facebook/');
$this->_obj->load->library('facebook', $config);
$this->_obj->load->remove_package_path(APPPATH.'third_party/facebook/');
And place the files for this library in the /third_party/facebook/libraries/ folder.
Note: It's a common mistake to place the files directly in '/facebook/' instead of in '/libraries/' (and also not mentioned in the documentation, too bad).
You can use the stripe native library by adding as codeigniter helper.
step 1: put the stripe package into helper directory
step 2: rename the init.php to init_helper.php
step 3: load the helper into your controller
$this->load->helper('stripe/init');
step 4: call stripe library
try
{
// set api key
\Stripe\Stripe::setApiKey('YOUR_SECRET_STRIPE_API_KEY');
// create customer
$customer_detail = \Stripe\customer::create(array(
'email' => 'customer_email#testdomain.com'
));
echo $customer_detail->id;
}
catch (Exception $e)
{
$error = $e->getMessage();
echo $error;
}
Try putting your library on application/libraries and then load your librarie with
$this->load->libraries('Stripe.php');

Categories