Integration odoo 9.0 with PHP - php

867/5000
Hello everyone!
I have a problem, in the place where I work they want me to create a login screen for the CRM so that the client, just enter their e-mail and password, and go directly to their CRM (without having to choose between all the databases ). The question is that you create a database and a login with php, clients at the beginning of the session ask all the data to the database so that it is directly connected with odoo.
When I bring all the data, I will put them in the corresponding field so that I send them to odoo (Work with odoo 9.0 and Ripcord). How can I establish that connection with odoo and that when it is successful, it redirects me to the client's CRM and leaves the login screen that believes it is hosted on a server?
I hope to have explained myself well, anything explained back. Thanks for your help in advance.
Regards!
Here is my code:
<?php
require_once('ripcord-master/ripcord.php');
$url = $ODOO_URL; //ODOO Server Url
$db = $user['codigo']; //Database Name
$username = $user['usuario']; //UserName
$password = $user['password_odoo']; //Password
$common = ripcord::client("$url/xmlrpc/2/common");
//Authenticate the credentials
$uid = $common->authenticate($db, $username, $password, array());
//Create Model Instance
$models = ripcord::client("$url/xmlrpc/2/object");
// Fetch the data by calling appropriate methods
$partner_field = array();
$partner_field=$models->execute_kw($db, $uid, $password,
'res.partner', 'fields_get',array(),
array('attributes' => array('string', 'help',
'type')));
?>
What I try to do is that when I verify that the user's data is correct, I redirect to the odoo page with the customer's CRM open.

Related

Consolibyte Quickbooks Connection Problem

I'm trying to connect my website (in Developer Mode, so Sandbox True, non https) to Intuit from the Consolibyte "docs/partner_platform/example_app_ipp_v3/index.php" file, but I keep getting the following error:
Uh oh, there’s a connection problem. Sorry, but the app didn’t
connect. Please try again later, or contact customer support for help.
View error details (for Developers) The redirect_uri query parameter
value is invalid. Make sure it is listed in the Redirect URIs section
on your app's keys tab and matches it exactly. Click here to learn
more about the redirect_uri query parameter.
I've set the Redirect Uri in my intuit developer account for this app to the same Return URL in the Consolibyte config.php (docs/partner_platform/example_app_ipp_v3/success.php), but it still isn't working.
Am I doing something wrong? I followed everything in the quick start guide correctly.
config.php code:
$oauth_client_id = '***';
$oauth_client_secret = '***';
// If you're using DEVELOPMENT TOKENS, you MUST USE SANDBOX MODE!!! If you're in PRODUCTION, then DO NOT use sandbox.
$sandbox = true; // When you're using development tokens
//$sandbox = false; // When you're using production tokens
// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'http://www.***.com/quickbooks/docs/partner_platform/example_app_ipp_v3/oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'http://www.***.com/quickbooks/docs/partner_platform/example_app_ipp_v3/success.php';
// This is the menu URL script
$quickbooks_menu_url = 'http://www.***.com/quickbooks/docs/partner_platform/example_app_ipp_v3/menu.php';
// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://username:password#hostname/database';
// $dsn = 'mysql://username:password#hostname/database';
$dsn = 'mysqli://***_intuit:***#localhost/***_quickbooks';
// You should set this to an encryption key specific to your app
$encryption_key = '***';
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
// The tenant that user is accessing within your own app
$the_tenant = 12345;
Your redirect URL doesn't match.
In Intuit's control panel it ends with success.php.
In your configuration, it ends with oauth.php.
The two URLs have to match exactly.
Also, make sure you're using the latest code from https://github.com/consolibyte/quickbooks-php - if you're using the latest code, you should have a config_oauthv2.php file and not just config.php.

How to create ftp in php?

Hello i want to create ftp for particular users.. I have searched on google but nothing found. So i have decided to put question on stackoverflow. I have tried below code but not working at all :-
$cpaneluser = "xxxxx"; // i have entered my cpanel user
$cpanelpass = "xxx"; //pwd
$domain = "testing.domain.com"; //here i have entered the domain
$fuser = "testing#domain.com";
$fpass = "mypwd";
$homedir = "/direcctorypath";
$url = "http://$cpaneluser:$cpanelpass#$domain:2082/json-api/cpanel?";
$url .= "cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=addftp&";
$url .= "user=$fuser&pass=$fpass&homedir=$homedir&quota=0";
var_dump($url);
$result = file_get_contents($url);
var_dump($http_response_header);
if ($result === FALSE)
die("ERROR: FTP Account not created. Please make sure you passed correct parameters.");
echo $result;
SEE OUTPUT
Every time its output coming FTP Account not created. Please make sure you passed correct parameters..
But i have entered the correct details. i Don't know why its not working.
So later on i have decide lets do with exec command but that also not working
Ref Url :- Creating FTP user accounts using FTP on server
exec("adduser -c 'testing#domain.com' -m testing123"); // this is not working at all
After checking above url i have added the username and password of ftp account. But i have one doubt where i passed the cpanel useranme and password in exec function. Can anyone tell me how to create ftp account of a user. Thanks in advance

Quickbooks ONline Using PHP from quickbooks-php from GitHub

I am using the quickbooks-php from GitHub. The version is quickbooks-php-master\docs\partner_platform\quickbooks-php-master\docs\partner_platform\example_app_ipp_v3.
I used this version 3 or 4 years ago and it work OK. Recently I wanted to try it again for a project. Since the last time I used it they only used OAUTH1 now they are using OAUTH2 for login and I'm not able to connect to my Sandbox account. I get a general error when the php coded tries to return the company name.
My question is do I need to make changes to the quickbooks-php-master\docs\partner_platform\example_app_ipp_v3 version in order to get it working again. I have the Development Keys (Client ID and Client Secret) from the developers site.
The config.php file is where you place these keys:
$token = 'xxx';
oauth_consumer_key = 'xxx';
`$oauth_consumer_secret = 'xxx';
The names of these keys have changed so it is a bit confusion as to whether these can work this way.
So the main question is does example_app_ipp_v3 work with OAUTH2 and if so can you direct me to the changes I need to make.
Any help on this would be great. If this version doesn't work with OAUTH2 I just need to know if that is the case so I can try something else.
OAuth2.0 support is being rolled out now. Check out the migration guide here:
https://github.com/consolibyte/quickbooks-php#oauth-10-to-oauth-20-migration
And the most recent updates. More updates to come. The configuration code changes a bit to accommodate the new OAuth 2.0 requirements:
$oauth_client_id = 'Q0ql65UCww8oAoiXfNdVyZ5WHoZ0kJ43XqstMhxGtM2UuA5WKu';
$oauth_client_secret = 'S60VXMXFygEOcb08DleS8iePUFyH81i4FhVrKaAB';
$sandbox = true; // When you're using development tokens
// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/success.php';
// This is the menu URL script
$quickbooks_menu_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/menu.php';
// This is a database connection string that will be used to store the OAuth credentials
$dsn = 'mysqli://dev:password#localhost/quickbooks';
// You should set this to an encryption key specific to your app
$encryption_key = 'bcde1234';
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere(
QuickBooks_IPP_IntuitAnywhere::OAUTH_V2,
$sandbox,
$scope,
$dsn,
$encryption_key,
$oauth_client_id,
$oauth_client_secret,
$quickbooks_oauth_url,
$quickbooks_success_url);

Twitter does not connect with localhost PHP

<?
// here we want to send the article to twitter
require_once('twitteroauth.php');
// Twitter Connection Data
$tConsumerKey       = 'xxxx';
$tConsumerSecret    = 'xxxx';
$tAccessToken       = 'xxxx';
$tAccessTokenSecret = 'xxxx';
// start connection
$tweet = new TwitterOAuth($tConsumerKey, $tConsumerSecret, $tAccessToken, $tAccessTokenSecret);
// the message
$message = 'Auto Tweet via PHP ...';
// send to twitter
$tweet->post('statuses/update', array('status' => $message));
?>
here is my code .. it does not send post tweet. is it about localhost or something else ?
I'm using xampp on windows7 ..
Which library are you using for OAuth? Is it for an app that you have made or somebody elses?
If you can edit and check the settings on the Twitter developer area, this question about using localhost with your twitter application might be useful for your callback when authenticating your app.
Twitter oAuth callbackUrl - localhost development
I found it useful when wanting to connect apps during development. Using 127.0.0.1.

How do you make a proper HTTP POST request to an API via PHP code? I'm doing something wrong

So I am trying to authenticate with a url (in a companies API) and send some information in to be checked. If the info is good, it sends me back what I need (string). If not, it sends back a string: "0". If there is an error, it sends back a string complaining the error. However, using this method from the CakePHP documentation of HttpSocket, I am being returned an HttpResponse object that is seemingly empty. It has no body, no status code, etc. What am I doing wrong? I am going to change the values because they are private for work.
App::uses('HttpSocket', 'Network/Http');
$user = 'username';
$pass = 'password';
$token = $this::_getToken($user, $pass);
$hash = $this::_getChallengeSalt($token);
$item = $this->Item->findById($id);
$url3 = 'example.url.com/api/path/to/code';
$http = new HttpSocket();
$http->configAuth('Basic', $user, $pass);
$data = array('id' => '1234', 'itemName' => $item['Item']['id'], 'hash' => $hash);
$results = $http->post($url3, $data);
i have seen your code but could not fine any mistake
but here i can suggest you to if I think you cannot talk directly HTTPS, as it is HTTP encrypted with the public certificate of the server you are connecting to. Maybe you can use some of the ssl functions in php. But, this will take you some time and frankly, there are easier things.
Just take a look at cURL (client URL), that has support for GET and POST requests, and also connecting to https servers.
let me know i can help you more.

Categories