I currently have a website up and running that uses the Twitteroauth classes (abraham's) and the Twitter API. It is all working as it should, however, I want to also run the project on my localhost for debugging/coding purposes so that I am not in danger of messing up my live version.
I am wondering if it is possible to run Twitterouth on localhost. I know that there are ways to manipulate the callback URL of the application on Twitter's site, however I do not want to do that as my live version needs the callback URL.
I hope this makes sense and I hope there is a solution out there.
Thank you.
It is possible to run Twitteroauth in localhost. You should make a copy of your project files from your website and copy it to your localhost.
You might see a file "config.php" where you'll define the callback url.
define('OAUTH_CALLBACK', 'http://localhost/path_to_callback.php file');
It will redirect you to your callback.php file and it works in localhost.
For running Abramham William's twitteraouth locally , you can create another test application on twitter so that it don't disturb the live version . Then instead of using localhost/ in your address bar , you should use the IP address of your localhost , this mistake by me consumed a lot of time .
Example :
127.0.0.1/twittertest/index.php and not localhost/twittertest/index.php in your address bar .
You'll need to give the same oauth callback in your twitter application .
Related
Im working on a website using Laravel in a Docker container on local. The webserver used is Nginx.
Im trying to implement Facebook's Graph API (the PHP API) and as Im developing on localhost and using Docker, any time I want to use the API I get:
Can't Load URL: The domain of this URL isn't included in the app's
domains. To be able to load this URL, add all domains and subdomains
of your app to the App Domains field in your app settings.
I tried adding the domain I use locally myapp.local:3000, also <my ip>:3000 or localhost:3000 but nothing works.
Here is the code:
public function facebookRequest() {
$fb = new \Facebook\Facebook([
'app_id' => 'MY_APP_ID',
'app_secret' => 'MY_APP_SECRET',
'default_graph_version' => 'v8.0',
]);
$callback = 'users/get-facebook-photos';
$helper = $fb->getRedirectLoginHelper();
$permissions = ['user_photos'];
$data['fb_url'] = $helper->getLoginUrl($callback, $permissions);
$loginUrl = $helper->getLoginUrl(base_url().'/users/get-facebook-photos', $permissions);
echo 'Log in with Facebook!';
}
What I need to do to develop using Graph API and Docker? There's some option to bypass domain filter or what should I do?
Seems like you're using your application to request a token from facebook servers and when the token is created, you'll end up being redirected on to the original destination. The redirect location cannot be "localhost" it should be a valid location ... like a website. If you want to make this work locally you could edit your /etc/hosts file to map local.example.com to 127.0.0.1 and use this domain for redirections in tests/QA, so that when your app gets redirected, it attempts it via the localhost.
Another suggestion (found by searching for the exact but more generic parts of the error "Can't Load URL: The domain of this URL isn't included in the app's domains") suggests:
add "https://apps.facebook.com/" in valid OAuth redirect URIs under https://developers.facebook.com/apps/your-app-id/fb-login/settings/
Well finally got a solution (not the one I wanted). I was using a custom domain defined on my host file. That didn't work for Facebook. I needed to use localhost (not even 127.0.0.1) and whitelist localhost on Facebook Developers.
So, if you have this issue, you can do this workaround and use localhost instead of custom domain. Nevertheless, my ideal solution would be using custom domains.
I am working with a designer and I'd like them to have access to the interactions I've implemented on the site we're working on. However this time, I have 2 issues. My localhost is configured to a subdomain:
http://store.teststore:3000/ and we're on different networks. Is there anyway to work around this?
ngrok should work for you. Download and install it following these instructions here: https://ngrok.com/download. Documentation on how it is used can be found here https://ngrok.com/docs. Once installed running the below command should work for you (depending on the hosting environment):
ngrok http -host-header=rewrite store.teststore:3000
You will need to give the URL generated by ngrok and displayed in the cmd prompt to the designer.
Update: Handling absolute redirects
Based on your comment it sounds like, after login, your site does an absolute redirect (the full URL is specified). If it is possible I would change your code to do a relative redirect where the domain is omitted. You could also make your root domain configurable in the absolute redirect and configure it to be the ngrok domain provided for now. Lastly, you could attempt to configure your DNS with a CNAME record following ngroks Tunnels to custom domains documentation. This last option, however, requires a paid for ngrok subscription.
Install ngrok if you haven't yet and CD into your project directory and invoke ngrok. Note Your application must be running locally on the same port number ngrok will be running.
I'm using ahoy_email ruby gem to track the emails I send. It should give me the time at when it is opened and clicked. But it's not working properly to give the time. What I'm missing.
Note: I run the project in my localhost
I had a similar issue. Make sure your server is accessible from the outside world so the image can be fetched.
A little background: I eventually figured that it worked from the godaddy webclient but not gmail, and thats because the webclient was just loading the image from my browser (so it could see my 'localhost'), but I believe gmail uses a proxy server to load images (https://filippo.io/how-the-new-gmail-image-proxy-works-and-what-does-this-mean-for-you/) so it couldn't find it.
I've been using ngrok lately to make my localhost outside accessible (temporarily!) and been liking it.
Have been developing a Wordpress theme using MAMP (localhost:81), and I am now testing some responsive parts on iOS (using my IP (192.168.1.15:81).
Some images are hard-coded (i.e. not changeable from the admin), using the following code:
<img src="<?php echo get_template_directory_uri(); ?>/images/brand-id.svg" onerror="this.src=<?php echo get_template_directory_uri(); ?>/images/brand-id.png" alt="Brand Name" />
It displays correctly both on localhost and IP, from desktop, but using the IP on iOS (8.1), it cannot find the resource, because it loads it in this form:
http://localhost:81/alexe.ro/wp/wp-content/themes/brand/images/brand-id.svg
I am using the Relative URL Wordpress plugin, but that seems to only work for loading the css/js/fonts.
Other details: the dynamic images (the ones uploaded from the cms) load perfectly.
How can I get the 'hard-coded' resources to switch between localhost and the IP, if necessary?
Thank you in advance.
The problem isn't related to IOS, it will fail to read the correct path from any machine in the LAN, apart from your dev one.
One of the solution is:
To make WP to always run under http://IP:port rather than http://localhost:port
In your case, it looks like your WP is in a sub directory /wp, then login to admin panel, and go and update as below:
Settings > General > WordPress Address >> http://192.168.1.15:81
Settings > General > Site Address >> http://192.168.1.15:81/wp
It's also recommended to set the dev machine with a static/preserved IP address on the router, so it will always receive the same one.
I also like the solution posted by #asherstoppard Well, you can play around and find which fits you the best.
One more tip: Backup your database first, in case anything bad happened.
Try adding the following to your wp-config.php file.
define('WP_HOME','192.168.1.15:81');
define('WP_SITEURL','192.168.1.15:81');
Your site_url() will be set to localhost:81 and as such will be attempting to access localhost on your device through get_template_directory_uri().
I'm working on implementing omniauth into a Rails project. My problem is that the authentication providers - Twitter, Google, Facebook etc all require me to create an application with a url that limits authentication requests from anywhere other than the url. I need to be able to to test locally but also run code in production, but Facebook for example doesn't allow 2 domains and doesn't allow localhost anyhow.
So what are my options?
At work, we have multiple applications setup for the different environments. On local, add an entry in /etc/hosts (assuming you are on linux) eg: 127.0.0.1 mydomain.local.
On the facebook app setup for the local environment, add this as the url. Most things, except where facebook needs to scrape your site (Like buttons) work.
Here's a blog post with my solution: http://make.bettermistak.es/2012/05/03/how-to-create-a-local-sandbox-facebook-app/
Here's the relevant bit: "Facebook verifies that all requests for your app are coming from the right domain–they don’t allow requests from localhost or 127.0.0.1–and this info can be updated in your apps settings under Hosting URL. Add “local.herokuapp.com” to your Hosting URLs and save this setting. Then edit your /etc/hosts file so that local content is under the domain local.herokuapp.com. This file is hidden, so from the command line enter sudo vi /etc/hosts. (Substitute your favorite editor for vi.) We need to use sudo, because this file is locked. Add the line “127.0.0.1 local.herokuapp.com” below “127.0.0.1 localhost” and save and quit your text editor."
As far as I know, you must sing up two apps for you app.(one for remote side, one for local side)
Fortunately, there is a way to reduce the complication(Assuming you are working on linux):
You can configure you .bash_profile (local machine and remote machine separately):
export YOURAPP_APP_ID="XXXXX"
export YOURAPP_APP_SECRET="XXXXX"
And use ENV['YOURAPP_APP_ID'] and ENV['YOURAPP_APP_SECRET'] in your code.
For example, you can code like this in rails:
config.omniauth :facebook, ENV['YOURAPP_APP_ID'], ENV['YOURAPP_APP_SECRET']
By this way, you can use the same code in both local and remote side. It will be much easier for maintaining.
If you are using Heroku to host your application, you can refer to this page to config the environment variables.
I have created two apps on Facebook one of which i run in sandbox mode for development purposes. Would that be an option for you?