Dropbox PHP SDK not working on production server - php

I am playing around with Dropbox PHP SDK and I have a wired problem. On my localhost environment it works like a charm, but on my server it does not. I have ssl and the dropbox redirect urls is: https://flaviuscojocariu.com/arhitecta/dropbox_finished.php
I don't understand where the problem can be, as I searched my entire code for http://localhost/ links and replaced everything. I get only the 500 error and I don't understand why.
Can someone advice?
If needed I can provide more code. This is the code which I use for auth.
<?php
session_start();
$_SESSION['user_id'] = 1;
require __DIR__.'/../vendor/autoload.php';
$dropboxKey = '***';
$dropboxSecret = '***';
$appName = '***';
$appInfo = new Dropbox\AppInfo($dropboxKey,$dropboxSecret);
// Store CSRF token
$csrfToken = new Dropbox\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
// Define auth details
$webAuth = new Dropbox\WebAuth($appInfo, $appName, 'http://localhost/arhitecta/dropbox_finished.php', $csrfToken);
$db = new PDO('mysql:host=127.0.0.1;dbname=arhitecta;', 'root','');
//User datails
$user = $db->prepare("
SELECT * FROM users WHERE id = :user_id
");
$user->execute(['user_id' => $_SESSION['user_id']]);
$user = $user->fetchObject();

Related

openid connect to identify server in php

I'm using https://github.com/jumbojett/OpenID-Connect-PHP this library to auth an user from identify server 4.
I'm trying to connect to identify server which has this settings
Scope : offline_access
Response type: code id_token
DefaultScheme = “Cookie”
Error I'm getting:
Sorry, there was an error : unauthorized_client
Invalid grant type for client
My code
$issuer = 'issuer';
$cid = 'clientid';
$secret = 'clientsecret';
$oidc = new Jumbojett\OpenIDConnectClient($issuer, $cid, $secret);
$oidc->addScope(array('openid', 'offline_access'));
$oidc->authenticate();
$oidc->requestUserInfo('sub');
$user = $oidc->requestUserInfo();
session_start();
$_SESSION['user'] = $user;

Quickbooks Online Error PHP

When I attempt to connect to QBO via the Consolibyte package I downloaded I get an error.
Error Code: internal_error
Message: Error getting application from request token
You can contact us for further assistance. Error
Id:ixnkryec2iu513ef45f3f5xv-12940655
I have set up the config.php file as directed in the instructions and even got to the point of authorizing the application with Quickbooks but now when I navigate to the page it indicates that I am not logged in and when I click the "Connect to QuickBooks" button on the index.php page I get the error above. I'm not familiar enough with the process to know where to start troubleshooting this problem and any help would be greatly appreciated.
Link: http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/
example_app_ipp_v3/config.php code
require_once dirname(__FILE__) . '/../../../QuickBooks.php';
$token = 'f5ddd229b1d19b4153b8218b08b97897050f';
$oauth_consumer_key = 'qyprdYvvyNLq1om6FSw0xLebctZEAz';
$oauth_consumer_secret = 'KCLYZRgZ4LnHUB35AzvylxnH6c8CDCyjhva8I9Gp';
$sandbox = true; // When you're using development tokens
$quickbooks_oauth_url = 'http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/oauth.php';
$quickbooks_success_url = 'http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/success.php';
$quickbooks_menu_url = 'http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/menu.php';
$dsn = 'mysqli://myusername:mypassword#localhost/databasename';
$encryption_key = 'bcde1234';
$the_username = 'DO_NOT_CHANGE_MEddd';
$the_tenant = 'sdfaswrqwerqwr';
if (!QuickBooks_Utilities::initialized($dsn)){
QuickBooks_Utilities::initialize($dsn);
}
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret, $quickbooks_oauth_url, $quickbooks_success_url);
if ($IntuitAnywhere->check($the_username, $the_tenant) and $IntuitAnywhere->test($the_username, $the_tenant)){
$quickbooks_is_connected = true;
$IPP = new QuickBooks_IPP($dsn);
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);
if ($sandbox){
$IPP->sandbox(true);
}
$realm = $creds['qb_realm'];
$Context = $IPP->context();
$CompanyInfoService = new QuickBooks_IPP_Service_CompanyInfo();
$quickbooks_CompanyInfo = $CompanyInfoService->get($Context, $realm);
} else {
$quickbooks_is_connected = false;
}
None of the tokens or OAuth credentials you have in your code match what you have in the screenshot.
Fix your tokens and OAuth values.
$token = 'f5ddd229b1d19b4153b8218b08b97897050f';
$oauth_consumer_key = 'qyprdYvvyNLq1om6FSw0xLebctZEAz';
$oauth_consumer_secret = 'KCLYZRgZ4LnHUB35AzvylxnH6c8CDCyjhva8I9Gp';

Post tweet option using php only working for me, how to make it general?

Hi all i developed an application for posting tweet using PHp with twitter api 1.1. But that option is only working for me only. If any one authenticated and try to send tweet using that. It's posting tweet on my wall.
How to make this generalized for anyone.
YOUR_CONSUMER_KEY = 'xxxxxxxxxxxxxx';
YOUR_CONSUMER_SECRET = 'xxxx';
$twitteroauth = new TwitterOAuth(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET);
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken('http://xxxx/xxxx/getTwitterData.php');
//print_r($request_token);
$twitteroauth = new TwitterOAuth(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET, $request_token['oauth_token'], $request_token['oauth_token_secret']);
$tmessage = $_POST['message'];
$content = $twitteroauth->post('statuses/update', array('status' => $tmessage));
it's posting tweets on your wall because you're using access token and secret of the app, or you're the authenticated user. You need to log in the user you want to post for, get their access token and secret, then use consumer key, secret, user access token and user access secret to post on their behalf.
It's a bit unclear what you're trying to do, but here's a sample post action with Abraham William's library, which you're using:
require_once('twitteroauth.php');
$key = "***";
$secret = "***";
$token = "***";
$token_secret = "***";
$connection = new TwitterOAuth($key, $secret, $token, $token_secret);
$message = "whatever";
$status = $connection->post($message);
$response= $connection->http_code;
if($response !=200){
echo "ERROR";
}else{
echo "life is good";
}

Facebook PHP Sdk Access Token

I know there are tons of topics
on this question, but every single one that I've seen, seems to have no solution at all!
I'm getting the infamous "Oauth Exception - An active access token must be used to query information about the current user" and I don't know what to do.
My facebook connect was working perfectly fine until yesterday, now, it stopped working all of a sudden today.
Can anyone please help me with this?
I'm using php sdk to connect the user to facebook in a pop-up window, then I make him autorize my app and redirect the window to a php called facebookReturn.php.
In this file, I'm supposed to get the user info, save it on Session, then close the window and refresh the main page behind.
Here are my codes.
index.php:
require_once 'phps/facebook.php';
$config = array();
$config[appId] = 'xxxx';
$config[secret] = 'xxxx';
$config[fileUpload] = false;
$facebook = new Facebook ($config);
$facebookId = $facebook->getUser();
echo "<br>facebook id: $facebookId";
if ($facebookId) {
$userProfile = $facebook->api('/me');
$logoutUrl = $facebook->getLogoutUrl();
}
else {
$params = array ();
$params[scope] = 'publish_stream, user_birthday, email, user_activities';
$params[redirect_uri] = 'http://www.mydomain.com.br/phps/facebookReturn.php';
$params[display] = 'popup';
$loginUrl = $facebook->getLoginUrl($params);
}
facebookReturn.php:
require_once 'facebook.php';
$config = array();
$config[appId] = 'xxxx';
$config[secret] = 'xxxx';
$config[fileUpload] = false;
$facebook = new Facebook ($config);
$user = $facebook->getUser();
$userProfile = $facebook->api('/me');
Thank you in advance.
Remomber: Facebook token expires in 60 days.

Facebook SDK-PHP : getting the uid of the connected user

I'm trying to get the UID of the connected user with Facebook SDK for PHP, but it doesn't work, and all other things work properly; it means that the problem is not in the connection to the application.
I tried this code but it is always returning 0 while I'm connected to Facebook; I even tried with other accounts but no solution.
$uid = $facebook->getUser();
$facebook = facebook_get();
$uid = $facebook->getUser();
echo $uid;
and here's facebook_get()
function facebook_get()
{
include('lib/fbapi/facebook.php');
$config = array();
$config['appId'] = '...';
$config['secret'] = '...';
$facebook = new Facebook($config);
return $facebook;
}
Can you post your authentication code you've coded or you're using?
If you post, we can look into your code and give you the answer to why it's returning 0, it could be your authentication code which is not coded properly or it could be config error.etc.

Categories