Facebook share not working(using direct uri) - javascript

I am trying to create an fb share button in my website.
When user clicks on button(fb image) it gets redirected to http://www.facebook.com/sharer.php?u=.
I m setting url as location.href dynamically through js
url is encoded automatically and when i click on button i see http://www.facebook.com/sharer.php?u=http%3A%2F%2F ...
url has a parameter x. it is in the form http://website.com/?x=
after clicking i get facebook error saying this page isn't working. Unable to handle this request.
i tried encoding location.href through js (encodeURIComponent function) but still it doesn't get affected.
There are ways through fb sdk but i am trying the simpler way.
I am using same on twitter and its working fine. (Twitter url is http://www.twitter.com/intent/tweet?text=).
After searching on internet i am unable to come up with any solution yet.
Also tried opening http://www.facebook.com/sharer.php?u= and putting url manually. Still i get the error.

There was no error in setup. But adding additional tag for og:url which pointed to incorrect url was the problem.
Removing meta tag worked.

Related

How do you use a URL javascript injection to create an iframe on any specified website?

I've looked for answers to this question, but the closest that I could find all had to do with using javascript to create an iframe on a user-owned page. I specifically want to inject javascript into a website via the URL in order to add a frame to Google at the bottom of that website. The syntax which I have been using is as follows:
Javascript: var ifr=document.createElement('iframe');ifr.setAttribute("src","www.Google.com");ifr.width=100+'%';ifr.height=500+'px';document.body.appendChild(ifr); void(0);
Unfortunately, every time that I submit this, the iframe throws a 500 internal server error. Can anybody lend advice as to why this may be happening?

Facebook didn't crawl the og:image when using sharethis

I have used sharethis plugin in my website. When I shared a particular page it does not crawl the correct image in the share popup window. But after sharing it to the facebook, I can see the correct image. It happens for a particular page only.
I have checked the og:image property and the image meets all its requirement. The dimension of the image is 362x550. I have no idea why it doesn't crawl the image.
Please anyone assist me to get resolve this issue.
Here is the link I shared via sharethis.
Page Link:
https://www.getcensored.com/m/photocontest/view/Kassie-Tocko
I can't give you exactly solution, but will try to give you at least some direction.
So what I observed with FB debug tool: https://developers.facebook.com/tools/debug/og/object/
Put initial link https://www.getcensored.com/m/photocontest/view/Kassie-Tocko#st_refDomain=&st_refQuery= and you will see that FB will see your og:image tag
Put some other anchor https://www.getcensored.com/m/photocontest/view/Kassie-Tocko#test1 and click "Fetch new scrape information", you will see a message about parsing error, then try to fetch again and you will see og:image
Try repeat 2. several times with different anchors
I had a similar issue, but the problem was 301 redirect, but you don't have it. May be try disable https and test FB sharing via http, just for test. May be problem is with your SSL negotiation time. Some info related FB and SSL here http://www.webpagetest.org/forums/showthread.php?tid=11788
For facebook to get to your image it needs the total url to your image and not the relative url..
Example of tht url that facebook expects to be in its og:image tag content :
http://www.exmaple.com/images/img1.png
I hope this helps you.

WWW::Mechanize::Firefox open url error

Am using WWW::Mechanize::Firefox in perl to automate a process. I can login without hassle by supplying the required fields and posting to the URL.
URL: hxxp://www.somesite.com/login-link.php
The above URL changes upon successful login to
hxxp://www.somesite.com/app/default.php
When I follow on any link, the URL doesn't change, but the content div would. When you open the link directly on the browser it i.e hxxp://www.somesite.com/app/profile.php?id=3 it doesn't load the parent div/frame which is hxxp://www.somesite.com/app/default.php.
My question is that, is it possible to get($url2) whilst maintaining/keeping the parent div.
Fixed the issue for anyone interested I used the EVAL function to achieve this

Read address bar url from a flash site

my dear friends..
I have a flash site, where when a user clicks on a link the page does not reload but the content changes with flash(like any normal flash site). So for example if user click on products page, the product page content is displayed, and the url in the address bar also changes from "domainname/index.aspx" to "domainname/index.aspx#/products"
I need to get this url from the address bar, and if i use "window.location.href" it returns "domainname/index.aspx". Does anyone know whether it is possible to read the url from the address bar which is changed by the flash.
Thanks in advance !!
Under ActionScript 3 (not sure about other versions), it is possible to invoke JavaScript functions in the client. You could use an ExternalInterface call to call a function that returns the URL from JavaScript (which should just be window.location).
The last part of the URL (after the # character) is know as the hash and you can read it with location.hash ;)
I would give jQuery history plugin a try. It detects when the URL changes with a hash etc.
http://tkyk.github.com/jquery-history-plugin/
And you could simply send the Flash object the url when the jQuery history plugin detects a change :)

Creating a tweet button without opening a new window

I'm looking to add a "tweet this" button to a site. Simple enough, right? The catch is that the site is meant to run on an embedded platform that doesn't particularly handle popup windows, so I'm trying to do everything inside the page.
I'm able to successfully create my tweet button, attach an onClick handler to it, and construct a proper twitter.com/share URL for the relevant content. All works fine when I open that URL in a new window with window.open. However, if I try to open the URL in an iframe, nothing loads inside the frame. Even loading http://twitter.com into the iframe fails in the same way. However, loading Google or any other website seems to work just fine.
Any thoughts on what I'm missing here? Thanks! --zach
Edit:
Yep, they are detecting the iframe on load and blanking the page:
if (window.top !== window.self) {
document.write = "";
window.top.location = window.self.location;
setTimeout(function(){ document.body.innerHTML='';},1);
window.self.onload=function(evt){document.body.innerHTML='';};
}
Any reasonable way to get around this, or am I stuck writing my own auth pipeline through oauth? I don't need anything from their API, just letting users tweet to their own accounts.
Twitter (like Stack Overflow) is probably using some Javascript to ensure they're not being presented in an iFrame:
if(top!=self){
//hates you
}
I ran into something similar recently, and ended up re-doing part of my app without the iFrame element.
Go and get a developper account on twitter and things are made easy for you :)
Can you simply redirect the the twitter share URL? I'm guessing they want to be careful about opening the window in iframe's to prevent malicious sites from tweeting in a user's account without giving the user a chance to first confirm their intent to send this tweet.
You said window.open worked fine for popping up the url in a new window but have you tried popping it into the parent frame?
twtWindow=window.open([url],'_parent',[specs])
#yuval Unfortunately for you, the twitter url goes to a page that has the X-FRAME-OPTIONS:SAMEORIGIN header set in the response. It's not a Javascript check. The browser will simply refuse to render the page after seeing the header. This is done to prevent a clickjacking attack, usually done to steal a user's password.
So your only other option is really to redirect your current page with window.location.href=url.

Categories