I am working on some JavaScript that receives the URL of a page, like fotolog;
http://www.fotolog.com/okendo/18551692/
And I want to search in this website to get the source URL of the image and display it in my website.
I want the URL of the main image but I don't know how.
Thanks in advance.
You can use YQL to fetch the content of the site adn use XPath to pick only the specific node. This all can be done by using AjaxP call.
Here is sample YQL which shows an example for the URL mentioned in your question
Related
I need to get the URL of each video in a library with JavaScript (I don't know how many videos will be in the library). I also need to get specific information about each video, such as date created. How would I do this? I am using a Script Editor web part to execute the JavaScript.
You could use rest API to get the information you wanted.
/_api/web/lists/GetByTitle('library title')/files
/_api/web/GetFolderByServerRelativeUrl('/sites/dev/Doc')/Files
Get to know the SharePoint REST service
Rest call with the below url will get you what you looking for
/_api/web/lists/getbytitle('" + youlistname + "')/items?$select=*,FileRef/FileRef"
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=O44zOeYcEXs&key={API_KEY}
A url like the above returns a particular videos' information, but the description is plain text. Although when we visit that particular video (https://www.youtube.com/watch?v=O44zOeYcEXs) the description is nicely formatted html.
I've been researching but haven't found any means to extract the complete html description of a video using the API.
Any pointers ?
These are different questions :
https://stackoverflow.com/questions/25034187/how-to-get-the-entire-youtube-video-description-using-c-sharp-and-youtube-api-v3
Getting complete description of video using YouTube API v3
Most of the Google APIs the YouTube v3 API included returns data in JSon format, basically you get a string back. If you want it formatted nicely as html you need to do that yourself.
Youtube API V3
For each resource type, the guide lists one or more data
representations, and resources are represented as JSON objects.
The other answer is correct but doesn't exactly explain what is going on. Youtube descriptions are supposed to be plain text and the only way to post links are with the full URL. You can't hyperlink snippets of text or use any other html. I assume this is to prevent malware spreading and several other issues.
Youtube detects and linkifys URLs in the description when you open a video. You would have to process the plain-text description for links and add the html a href tags yourself. One way to do that is to use Regex to detect URLs.
Javascript for uploading videos
https://developers.google.com/youtube/v3/docs/videos/insert#examples
I've used the example code and modify by changing the Client ID.
What I hope to achieve is using Javascript to get the URL or Video ID return which I can store at the database to use later.
The example code will show the video after it has successfully uploaded, when I click on the video, there is an option to get the video url. Is it possible to get the url automatically by javascript?
I've search for this topic but I can't find any similar solution.
Ok. This might have been asked several times but my problem is slightly different. I have following page tab in my facebook application:
Facebook Page Tab
This facebook page tab has my website embedded as iframe into it. What I want is that is to get the URL of current page inside my application.
For example, if you open above link you see facebook URL in your browser(obviously) address bar. In my iframe I just want to retrieve the URL of the parent page in which it is embedded.
I know same-origin policies in Javascript don't allow playing with cross-domain parent page's markup using javascript but I just want to retrieve the parent page URL, thats it.
Is that possible in ANY way?
Any way to access the address bar URL in my PHP application?
Thanks.
You probably don’t need the “actual URL”, but only the page id, I assume …? That you can get by decoding the signed_request parameter that gets POSTed to your app on initial load into the iframe.
How to “decode” it is described here, https://developers.facebook.com/docs/facebook-login/using-login-with-games#parsingsr
If you’re using the PHP SDK, that has a method already that does this for you.
You can use this to access it in JavaScript:
top.location.href
"top" is better than "parent". Because if your iframe is itself in another iframe then parent will return that iframe's location. "top" will return the highest location.
This will be a tough one, because CORS forbids to access the outside frame:
The referrer doesn't help very much either.
If you want to use the signed_request, and want to send custom data/parameters to your app, have a look at https://developers.facebook.com/docs/appsonfacebook/pagetabs#integrating
You can then fill the app_data parameter, and decode that in your app.
Try one of these:
parent.document.location
parent.window.document.location
parent.window.location
parent.document.location.href
I'm not sure if this will work on facebook though
I want to load a external webpage on my own server and add my own header. Also i need to use the data from the external website like url and content (i need to search and find specific data, check if i got that data in my system and show my data in the header). The external webpage needs to be working (like the buttons for opening other pages, no new windows).
I know i can play with .NET to create software but i want to create a website that will do the trick. Can this be done? Php + iframe is to simple i think, that won't give me the data from external website and my server won't see changes in the external url (what i need).
If it's supposed to be client-side, then you can acquire the data necessary by using an Ajax request, parsing it in JavaScript and then just inserting it into an element. However you have to take into account that if the host doesn't support cross-origin resource sharing, then you won't be able to do it like this.
Ajax page source request: get full html source code of page through ajax request through javascript
Parsing elements from the source: http://ajaxian.com/archives/html-parser-in-javascript (not sure if useful)
Changing the element body:
// data --> the content you want to display in your element
document.getElementById('yourElement').innerHtml = data;
Other approach (server-side though) is to "act" like a browser by faking your user-agent to some browser's and then using cUrl for example to get the source. But you don't want to fake it, because that's not nice and you would feel bad..
Hope it gets you started!