I would like to mimic Facebook's functionality where when you attach a link, it will read the meta data and image automatically:
Anyone know how to accomplish this interface functionality with jQuery?
It's not reading meta data of the image, it's reading actual data from the page. It does this, probably, with cURL:
http://php.net/manual/en/book.curl.php
tutorial:
http://phpsense.com/php/php-curl-functions.html
You can't do cross domain scripting with JavaScript so you will have to use a server side language such as PHP and then have PHP crawl the page and find the main content area of the description of the page... Hope that helps :\ it's not really a front end type of thing.
Related
Gmail and Facebook is able to change the URL where you can still use the back and forward buttons but the page's HTML DOM doesn't change fully. How are they doing this? I know they are using javascript, but what other technologies are involved in this magic?
They use the History API to change the URL and AJAX to update part of the site content.
Twitter has implemented this to their site as well, they explained it in detail on thisTwitter Blog
That's done with the History API.
The trick behind the libraries and components they use is AJAX (Asynchronous Javascript and XML). It's a way of getting information in JS without having to reload the page.
I'm looking to get some data from a Facebook page of a restaurant, but I'm kinda stuck. I want to load some divs from the facebook page of the restaurant, then get the ID's of the divs, since they contain some information i would like to use. Ive tried using the .load function from jQuery, but no luck. Of all the answers I've seen, they all include a url that's something like somefile.html. Is it possible to load the divs ids and some innerHTML from a live page like Facebook? Are they somehow downloading the html to a file then using that? Keep in mind I know nothing about PHP, so any solutions? Thanks!
The right way to do it would be though Facebooks graph API, take a look at this site and see if it offers the information you need https://developers.facebook.com/docs/graph-api/reference/page/
NOTE
As comments have pointed out, "web scraping" is FORBIDDEN on Facebook.com by Facebook policy. http://www.facebook.com/apps/site_scraping_tos_terms.php
Technically, I don't think this is possible with Facebook and just JavaScript.
In general, using just JavaScript, one solution would be to load the (external) site like FaceBook into an Iframe, and then grab all the DIVs and search the DOM that's loaded into the iFrame. However, I believe FaceBook (and other sites) set something called "CORS Request Headers" which prevent the page from loading into an iFrame -- also, as far as I know, this cannot be hacked around except to use another language to pull the HTML as a file (like with PHP).
Sources:
Facebook Forbids iFrames
JavaScript, Load Page in iFrame
I want to integrate this external example link on my web page. I am using PHP scripting language.
I have used file_get_contents, wget and all things but its only get HTML content.
I want to load entire site on my webpage. I don't want to use Iframe and tags because of security purpose I cant share URL with Users.
So please give me advice on this.
Is this we can do like how the proxy site works? Please help me on this.
Thanks in advance. :)
I have been reading up on here about how to hide the source URL in an iFrame using Javascript and Jquery, but for some reason, I haven't found a solution that works so far with Wordpress.
So short and sweet, I am trying to hide a URL for competition reasons, I'm about to launch a new web page using an iFrame to display content from another website that I subscribe to and pay quite a bit of money for their services. So I don't want my competition to know about them and copy what I do.
What would be the best way that I could mask the HTML source link in the iFrame? I use the latest version of Wordpress to host my site.
Alternatively, I am open to more advanced solutions.
Thanks in advance.
I'm not stealing anything. I'm a businessman who pays taxes and I pay $1400 per year for the web service that I use and I don't want my competitors STEALING MY set up
Ok I'll take you at face value. As has been pointed out in comments, it's impossible to do this with plain HTML or Javascript. It simply can not be done. There is no way to prevent a user of a browser from seeing the URI's that are contacted. Period.
That being said you could:
Retrieve the HTML from the 3rd party with your web server using something like CURL in PHP.
Take the result of the above and send it out on a URL of your choosing.
Create HTML with an <iframe> or whatever else you want to display the content from the 3rd party and point it at your new URL on your web server.
The above is not trivial to do correctly and will require some knowledge and work on your part. One issue with the above method will be: passing along javascript, images, css, etc... correctly so that they appear to come from your server.
Got a javascript updating description meta tag with a variable
$('meta[name=description]').attr('content',sharewhatever);
But the problem is that facebook cache is still going to have the old description if that page was shared before. Is there any way to deal with it without server side coding?
As far as I know, any client side manipulation will not work as FB crawls your page when you try to share a page to grab the meta description. Hence, it would only find the meta tags/content that were loaded with the page. So, your best bet is to set appropriate meta content server side.