Your credentials do not allow access to this resource [code] => 220 - magento

I am using twitter login for magento i configure everything but when get the user informations the give the following error.Your credentials do not allow access to this resource [code] => 220. if some body face this type of problem then help me and thanks in advance.
my code is
$CONSUMER_KEY='xxxxxxxxxxxxxxxxx';
$CONSUMER_SECRET='xxxxxxxxxxxxxxxxxxxxxx';
$OAUTH_CALLBACK='http://demo004.fmeaddons.com';
session_start();
$twitteroauth = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);
$request_token = $twitteroauth->getRequestToken($OAUTH_CALLBACK);
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
if($twitteroauth->http_code==200){
$url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
echo $url;
$twitteroauth = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
$access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']); $_SESSION['access_token'] = $access_token;
$user_info = $twitteroauth->get('account/verify_credentials');
print_r($user_info);
} else {
die('Something wrong happened.');
}

Make sure your keys were created with the correct permissions. You can check this in the "Keys and tokens" section of your Twitter developer dashboard:

Related

How i can get user access token in Dialogflow?

I am trying to find the users access token in the dialogflow because I am trying to associate it with botman.io but it is not working
this is the code :
$botman = app('botman');
$dialogflow = Dialogflow::create('token')->listenForAction();
$botman->middleware->received($dialogflow);
$botman->hears('weathersearch', function (BotMan $bot) {
$extras = $bot->getMessage()->getExtras();
$bot->reply('I'm working');
})->middleware($dialogflow);
How can I find my token ?
you can try this:
https://github.com/genkovich/DialogFlowBotManMiddleware
I tried to write detailed instructions :)

Google reCAPTCHA working on Local but not on my server

I have a form which requires a google reCAPTCH to be ticked. It is working perfectly on Local but does not work when I put it on the development server. I have replaced the registered keys to the ones appointed to me by Google.
It keeps outputting the error message.
The method in my form is post.
I do not understand why it doesn't work. Can someone please help me?
Here is my code:
$secretKey = "#######";
$captcha = $_POST['g-recaptcha-response'];
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
$throwErrorMessage = "You are a robot! ";
$throwError = 1;
$isvalid = False;
};
What version of ReCAPTCHA are you using? The docs on Google website here are pretty different than your code. In particular, you use the function file_get_contents while the documentation uses recaptcha_check_answer like in this example:
<?php
require_once('recaptchalib.php');
$privatekey = "your_private_key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again."."(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
?>
Can you post the error message?

Unable to Connect - http://10.0.2.2/test.php Local Host XAMPP

I have made a program using PHP Script, but whenever i am trying to run my script using Browser getting Problem Loading Page:Firefox can't establish a connection to the server at 10.0.2.2.
I have saved test.php under - E:\xampp\htdocs
test.php:
<?php
$objConnect = mysql_connect("localhost","root","");
$objDB = mysql_select_db("registration_login");
$_POST["sUsername"] = "testname";
$_POST["sPassword"] = "testpassword";
$_POST["sName"] = "testname";
$_POST["sEmail"] = "testemail";
$_POST["sTel"] = "testtel";
$strUsername = $_POST["sUsername"];
$strPassword = $_POST["sPassword"];
$strName = $_POST["sName"];
$strEmail = $_POST["sEmail"];
$strTel = $_POST["sTel"];
/*** Check Username Exists ***/
$strSQL = "SELECT * FROM member WHERE Username = '".$strUsername."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
$arr['StatusID'] = "0";
$arr['Error'] = "Username Exists!";
echo json_encode($arr);
exit();
}
/*** Check Email Exists ***/
$strSQL = "SELECT * FROM member WHERE Email = '".$strEmail."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
$arr['StatusID'] = "0";
$arr['Error'] = "Email Exists!";
echo json_encode($arr);
exit();
}
/*** Insert ***/
$strSQL = "INSERT INTO member (Username,Password,Name,Email,Tel)
VALUES (
'".$strUsername."',
'".$strPassword."',
'".$strName."',
'".$strEmail."',
'".$strTel."'
)
";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
$arr['StatusID'] = "0";
$arr['Error'] = "Cannot save data!";
}
else
{
$arr['StatusID'] = "1";
$arr['Error'] = "";
}
mysql_close($objConnect);
echo json_encode($arr);
?>
I recommend you to use your machine's IP Address in place of 10.0.2.2
So complete URL should look like this:
http://ipaddress/test.php
Note: Above solution for while you want to use Local Server via Android Emulator
Do you know where the 10.0.2.2 is coming from? By default localhost resolves to 127.0.0.1. This could potentially be your problem.
The problem you are experiencing wouldn't be from your PHP script. But rather the request isn't getting from your browser to your Apache web server.
- You'll want to ensure Apache is running.
- You could try making sure you are using localhost in the URL.
- You could check the apache log files under /Xampp/apache/logs/ and see if there is any recent errors being logged.
- You could also try a tool like Fiddler to see the exact response of the request.
Hope that helps.

Session management in Zend Framework 2

Trying to do site with administration on Zend Framework 2, set the authorization at mysite / admin / login. How to deny access if the authorization is not completed all the way after mysite / admin / ...?
In ZF1 for this I used «BaseController», but ZF2 want to check session in class Module.
class Module
{
public function onBootstrap($e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();
$config = $sm->get('Configuration');
// DB Adapter
$adapter = $sm->get('Zend\Db\Adapter\Adapter');
GlobalAdapterFeature::setStaticAdapter($adapter);
// Session
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions($config['session']);
$sessionManager = new SessionManager($sessionConfig, null, null);
Container::setDefaultManager($sessionManager);
$sessionManager->start();
}
}
Tell me whether I want to do? And in which direction to look?
Try to use Zendframe Work 2 EventManager.

Windows Phone with DropNet

I am writing a Windows App on Windows Phone Emulator to communicate with DropBox account and am using DropNet package from NuGet gallery.
The page that I am referring is: http://dkdevelopment.net/what-im-doing/dropnet/
Here are the steps I have done:
Step 1) Creating the client
DropNetClient GlobalClient = new DropNetClient("TOKEN", "SECRET", "testUserName", "testPassword");
I am not sure what goes in userToken and userSecret, it can't be hard-coded username and password!
Step 2) Requesting Token
GlobalClient.GetTokenAsync((userToken) =>
{
//Dont really need to do anything with userLogin,
//DropNet takes care of it for now
},
(error) =>
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show(error.Message);
});
});
Step 3) Building authorizing URL
var url = GlobalClient.BuildAuthorizeUrl("http://dkdevelopment.net/BoxShotLogin.htm");
Step 4) Redirecting browser to DropBox Login Page. After this, DropBox does allow to login, but it displays this warning: "The request to link the app is invalid" And more importantly, the browser does not get redirected to http://dkdevelopment.net/BoxShotLogin.htm. This indicates something went wrong. Not sure what though.
Uri testUri = new Uri(url.ToString());
WebBrowserTask task = new WebBrowserTask();
task.Uri = testUri;
task.Show();
Step 5) This does not work. GlobalClient.UserLogin.Token and GlobalClient.UserLogin.Secret does not get set.
GlobalClient.GetAccessTokenAsync((accessToken) =>
{
//Store this token for "remember me" function
GlobalClient.UserLogin.Token = accessToken.Token;
GlobalClient.UserLogin.Secret = accessToken.Secret;
},
(error) =>
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show(error.Message);
});
});
Anybody knows how to fix this?
Thanks!
I figured out the problem. In Step 2, request token needs to be stored in order to build correct authorize URL and that request token needs to be passed as the first parameter. However when I try to store in the statement lambda like this, it does not get stored. What's the issue here? I think it's the way I might be using lambdas.
GlobalClient.GetTokenAsync((userToken) =>
{
infoTextBlock.Text = userToken.Token;
GlobalClient.UserLogin.Token = userToken.Token;
}
(error) =>
{
});
Thanks!
The issue is in the following code:
UserLogin.Token = userToken.Token;
Assigning a value to token doesn't mean the underlying credentials are set for the request. This is only done when you call the following:
UserLogin = userToken;
Poor design in the class interface if you ask me. There should be no difference between calling UserLogin.Token = Something, and UserLogin = NewLogin (with regards to underlying business rules).

Resources