I'm following this Site which is a easy way to add a customised tweet box and button on my site and will help in update of post.
As per its functionality, once we write any messages in the textbox and click on tweet button we will get the twitter login pop up window, once we are authenticated our message will be posted on our twitter account wall.
But when i run this code, i'm getting the pop up window and once i provide my credentials the window closes but no message is posted in the twitter account. When i checked on my javascript console im getting error:
Unsafe JavaScript attempt to access frame with https://api.twitter.com/xd_receiver.html from frame with URL about:blank. The frame requesting access has a protocol of 'http', the frame being accessed has a protocol of 'https'. Protocols must match.
I dont know what this error means as my site through which im running the form is clorderdev2.uvacha.com
Below is my code :
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/anywhere.js?id=YOURCONSUMERKEY&v=1"></script>
<script type="text/javascript" src="Scripts/jquery.jtweetsanywhere-1.3.1.min.js"></script>
<script type="text/javascript" src="Scripts/jtweetsanywhere-de-1.3.1.min.js"></script>
<div id="jTweetsAnywhereSample"></div>
<script type="text/javascript">
$('#jTweetsAnywhereSample').jTweetsAnywhere({
showTweetBox:{
counter: true,
width: 380,
height: 65,
label: '<span style="color: #A4A4A4">What\'s happening?</span>',
defaultContent: '#jTweetsAnywhere',
onTweet: function(textTweet, htmlTweet){
alert('You tweeted: ' + textTweet);
}
}
});</script>
There's a better plugin to get Twitter tweets, and it's called livetwitter.
All the information you need is here:
https://github.com/elektronaut/jquery.livetwitter
The problem is that a script, somewhere, is trying to communicate between http:// and https:// protocols. For security reasons, JavaScript can't do that. This is most likely a bug in one of the libraries you're using.
I'd suggest using the official twitter implementation, if that's a possible alternative.
Related
Really struggling with facebook at the moment
I am trying to auth a user using openfb and facebook on an ios app being built with cordova (ionic). I have tried all the solutions I could find online.
My configuration is standard, and an almost copy and past of the openfb example. Without a callback url and with the following callback urls () I am getting the image you see on this facebook Security Warning while user has enabled secure login - iPhone
When I specify the callback url of http://localhost/oauthcallback.html. I get a Facebook mobile looking page with title, Error and message "Given URL is not permitted by the application configuration.: One of more of the given URLs is not allowed by the App's settings. It must watch the Website URL or canvas URL, or the domain must be a subdomain of one of the App's domains.
Note: works perfectly on web!
Can someone eplse point me in the direction to set this up once and for all on both Facebook and in openfb?
Please help!!!! :)
user1132726,
I struggled with that for days as well, looked over lots of forums, tried everything. Then I turned away to Javascript only.
We must have the right Javascript libraries in the right order. Some you can download, some you won't find easily.
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="js/cdv-plugin-fb-connect.js"></script>
<script src="js/openfb.js"></script>
Then you use regular Javascript logic to select your elements and use openfb API like:
openFB.login(
function(response) {
if (response.status === 'connected') {
alert('Facebook login succeeded, got access token: ' + response.authResponse.token);
// DO YOUR LOGIC HERE, I use perception: $.FacebookPerception.submit(response.authResponse.token);
} else {
alert('Facebook login failed: ' + response.error);
}
}, { scope:'email,public_profile,user_likes,user_friends'});
You must as well register your application at Facebook using Developers Console: http://developers.facebook.com . I used the website configuration with my main url: http://www.texugo.com.br/
I don't think you need other configurations. I tested only on Android. I don't know if you need to configure your App for Android at Facebook Console. I think it is not really used but haven't tested yet.
IMPORTANT: you need version 0.4 for openfb.js
Then you run Apache Cordova and deploy it to your mobile.
Further steps:
When you call Facebook it opens on a popop that Cordova applies
InAppBrowser, but I want to hide that ugly header that looks weird.
Integrate with Google+, LinkedIn and Twitter
Create OpenSocialAuth plugin
OBSERVATION: this is only working with Android, it does not work in web browsers. Gotta check it as well.
Hope it helps. Anything question me. I'm pretty sure I missed something.
See you.
I have a JavaScript app which uses the Google Drive API. I read how to open a standard sharing dialog here: https://developers.google.com/drive/web/manage-sharing
<head>
...
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script>
<script type="text/javascript">
init = function() {
s = new gapi.drive.share.ShareClient('<MY_APP_ID>');
s.setItemIds(["<MY_FILE_ID>"]);
}
window.onload = function() {
gapi.load('drive-share', init);
}
</script>
</head>
<body>
<button onclick="s.showSettingsDialog()">Share</button>
</body>
Seems like I do everything right, when I click my share button, the dialog starts loading but it can't be loaded.
In the console I see:
Refused to display 'https://drive.google.com/share?...' in a frame
because it set 'X-Frame-Options' to 'SAMEORIGIN'.
I've googled this error and I've seen that there are some similar questions in SO and other sites, but they don't help. I guess Google doesn't allow itself to be in a frame in a not-google-site (cause of "SAMEORIGIN").
What can I do to open sharing dialog in my app?
The "Launching the Google Drive sharing dialog in your app" page here states:
The URL of the page that launches the dialog must have the same origin
as the Open URL registered for the app.
If you then look at the instructions to "Configure the Drive SDK" here, you can see that the "Open URL" section reads:
There are two important things to keep in mind for the Open URL:
Make sure you give a fully qualified domain name for Open URL -- localhost won't work.
The URL must belong to you. After the app registration is complete, you'll need to verify your ownership of this URL in order to create a
Chrome Web Store listing. For more information, see Site Verification.
Hence your page which is launching the dialog does not have the same origin as the Open URL registered for the app in you Google Drive SDK settings. So to fix your problem correct the Open URL so that it has the correct URL i.e. a URL with the same origin as the Open URL. Note that you can change the Google Drive SDK settings via https://console.developers.google.com/project.
As well as making sure the Open URL is set correctly. You'll also need to substitute your Drive SDK app ID for 'MY_APP_ID'. You can find the App ID by following these instructions:
Goto https://console.developers.google.com
Click your project
Click "APIs and auth" on the left
Click the "Drive SDK" settings cog icon
The "App ID" can then be found under the "Google Drive SDK" title e.g. App ID: 47XXXXXXXX3
The problem was solved thanks to this answer https://stackoverflow.com/a/20742994/1185123
dan-man says in his answer:
Client ID You can find this in the Google Cloud Console - see above.
Mine is a 12 digit number, so yours will probably be too.
Mine client id looks like
175564412906-ui22fsaghkvkkj09j2bprku55m8k3d0d.apps.googleusercontent.com
I've used this id in
s = new gapi.drive.share.ShareClient('<MY_APP_ID>');
After reading the answer, I tried to use only first 12 digits of my client id. I didn't expect it to work, I was just desperate. But the strange thing, it works perfectly!
If somebody can explain why it works and why nothing about this is said in the documentation — you are welcome to answer!
Hi I'm using a wordpress plugin to allow user to comment using facebook and twitter accounts.
This is the page i am testing the plugin on http://blog.pcpal.co.uk/2012/04/first-raspberry-pi-computers-to-be-delivered/
When i click the facebook icon its opens up a windows where i sign into facebook ad then directs to a blank pages which has a JS error see code below
<html><head>
<script>
function init() {
window.opener.wsl_wordpress_social_login({
'action' : 'wordpress_social_login',
'provider' : 'Facebook'
});
window.close();
}
</script>
</head>
<body onload="init();">
</body></html>
# Error is Uncaught TypeError: Cannot call method 'wsl_wordpress_social_login' of null
If you can help then great..
Additional info
Only seems to do it with chrome
For security reasons the "window.opener" object is likely removed when you go to another domain (like Facebook). When it gets back to your site it's trying to tell the parent window (the blog) to refresh but it no longer has a way to communicate with it.
The plug-in should add some code to the parent page to watch for the pop-up window to close and then refresh itself.
See window.opener is null after redirect
I want to use JavaScript to make a simple http get.
I used jQuery to perform my request. My code runs on IE8.0 but not in Chrome (ver 6.0).
My page has the following code: (to simplify, i made a simple request to a html page, but my needs is other)
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<script type"text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<SCRIPT TYPE="text/javascript" >
function sendGet(){
$.get(
"http://www.google.pt",
function(data) {
alert('page content: ' + data);
});
}
</SCRIPT>
<head>
<title> Http Get Demonstration </title>
</head>
<body>
<p/>
<input type="button" value="Http Get" onclick="sendGet();" />
</body>
</html>
As i said, when i load this page on IE and press the button, i get the alert with the html code. But in Chrome the alert appears with empty text (null?). In Chrome Console from "Developer tools" i get the message: "XMLHttpRequest cannot load http://www.google.pt/. Origin null is not allowed by Access-Control-Allow-Origin."
Anyone can explain me what's the meaning of this message? And what i should change to my page run in Chrome?
Thanks
Due to same origin policy you cannot send AJAX requests to different domains than the one hosting your page. So unless your page is hosted on http://google.pt you cannot send an AJAX request to this domain. One possible workaround is to setup a server side script on your domain which will act as bridge between google.pt and the client or use JSONP if the distant domain supports it.
Although i can't remember if i changed any IE option, the Darin Dimitrov seems explain my problem.
I found some tricks can be used (beyond the Dimitrov answer):
use a PHP script:
http://jquery-howto.blogspot.com/2009/04/cross-domain-ajax-querying-with-jquery.html
configure IE by editing regedit (not recomended):
http://msdn.microsoft.com/en-us/library/dd565656(VS.85).aspx
(I belive there's some other way to disable cross domain protection without editing regedit. But i couldn't find it)
Are you opening the html file directly from a file (e.g. does the address bar say file://usr/path/to/the/file)?
We've found chrome won't let you 'ajax' in files from other domains when running under file://. However, in Safari it works fine.
Best solution for us is to use something like MAMP to run a local Apache server.
I am implementing a content sharing service, similar to Twitter and Facebook button. When the user visits a page, he will be able to click on my button, which will open a page in a new window that lets the user interact with my service. My service use 2 parameters: the current page's URL and title.
I have looked at the html code used to add the Twitter, Facebook and Printfriendly buttons and they all use Javascript code specific to their service.
For instance, this JS file must be included to add the Printfriendly button to your page:
<script src="http://cdn.printfriendly.com/printfriendly.js" type="text/javascript"></script>
For Facebook: <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
Twitter:<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
My question is do I need to write some Javascript code or can I just forward all the request to the server?
Thanks,
Olivier.
You need to write a bit of JavaScript code for the button (for the window to show up with the specified contents) and the main script (which is included like Twitter and facebook did as you mentioned)
You can get away with simple hyperlink. For example Facebook share button works like hyperlink: Share on Facebook.
The reason to use javascript or iframe is to have better control over user experience. So it is up to you to decide how you want to handle it.