I am creating a file picker using the skydrive/onedrive api
I get a list of files using the url:
https://apis.live.net/v5.0/'+folder_path+'/files?access_token='+onedrive_access_token
But this doesn't return a thumbnail for the files (unlike other api's, googledrive for example).
I would like to get a thumbnail for each file, if it exists.
I cant find anywhere in the docs how to do this - is there a way I can?
After complete the call, you should get some result like this.
{
"data": [
{
"id": "[file id]",
"from": {
"name": "...",
"id": "..."
},
"name": "[file name]",
"description": "",
"parent_id": "[parent folder id]",
"size": 12345,
"comments_count": 0,
"comments_enabled": false,
"tags_count": 0,
"tags_enabled": true,
"is_embeddable": true,
"picture": "[thumbnail url] <<< this is what you want",
"source": "[public preview url]",
"upload_location": "...",
"link": "...",
"height": 270,
"width": 480,
"duration": 22443,
"bitrate": 802928,
"type": "video",
"shared_with": {
"access": "Just me"
},
"created_time": "2013-01-01T07:27:17+0000",
"updated_time": "2013-01-01T07:40:44+0000",
"client_updated_time": "2013-01-20T16:26:54+0000"
},
]
}
Which "picture" is the thumbnail url that you want.
Related
I'm running a simple custom Google Chrome startpage consisting of a background .gif and a google searchbar. However, Google Chrome interprets it as something other than the default startpage, and thus won't show the native bookmark bar, unless the option to show it everywhere is checked (which is awkard for my monitor resolution).
The Google Chrome bookmarks file is located at C:\Users\UserName\AppData\Local\Google\Chrome\User Data\Default\bookmarks,below I'll paste a sample of its structure.
Just looking at this, do you think there's a way to either show the native bookmark ONLY in my custom startpage, or to fetch the information in that bookmarks file and display it on my own?
{
"checksum": "REDACTED",
"roots": {
"bookmark_bar": {
"children": [ {
"children": [ {
"date_added": "13222412798372622",
"date_last_used": "0",
"guid": "REDACTED",
"id": "7",
"name": "Whatsapp",
"type": "url",
"url": "https://web.whatsapp.com/"
}, {
"date_added": "13126908348807315",
"date_last_used": "13317078268398707",
"guid": "REDACTED",
"id": "8",
"meta_info": {
"last_visited_desktop": "REDACTED"
},
"name": "YouTube",
"type": "url",
"url": "https://www.youtube.com/feed/subscriptions"
}, {
"date_added": "13126908407318057",
"date_last_used": "13317078266263899",
"guid": "REDACTED",
"id": "9",
"meta_info": {
"last_visited_desktop": "REDACTED"
},
i have a problem with fetching images from strapi .
i tried a lot but it wont show any images , also when i post rich text ad try image it wont work, can somebody help me out !
const ApiUrl = ('http://localhost:1337')
const { id } = useParams()
const {loading , error , data } = useFetch('http://localhost:1337/reviews/ ' + id)
if(loading) return <p>Loading..</p>
if(error) return <p>Error</p>
return (
<div className={classes.root}>
<div className={classes.container}>
<img src={ApiUrl + data.image} alt={data.naam} />
<h2 className={classes.headertxt}>{data.naam}</h2>
also tried {review.image} {data.image.url} review.image.url
regardss
I think you need to check the documentation for your API (if you use rest API) or schema of GraphQl playground (if you use GrapQl).
Install Swagger UI documentation plugin to check schema.
This may fix your problem.
Maybe this can give you some directions.
LINK TO STRAPI CONTENT API GET
and this is what this should return for you:
{
"id": 1,
"title": "Restaurant 1",
"cover": {
"id": 1,
"name": "image.png",
"hash": "123456712DHZAUD81UDZQDAZ",
"sha256": "v",
"ext": ".png",
"mime": "image/png",
"size": 122.95,
"url": "http://localhost:1337/uploads/123456712DHZAUD81UDZQDAZ.png",
"provider": "local",
"provider_metadata": null,
"created_at": "2019-12-09T00:00:00.000Z",
"updated_at": "2019-12-09T00:00:00.000Z"
},
"content": [
{
"__component": "content.title-with-subtitle",
"id": 1,
"title": "Restaurant 1 title",
"subTitle": "Cozy restaurant in the valley"
},
{
"__component": "content.image-with-description",
"id": 1,
"image": {
"id": 1,
"name": "image.png",
"hash": "123456712DHZAUD81UDZQDAZ",
"sha256": "v",
"ext": ".png",
"mime": "image/png",
"size": 122.95,
"url": "http://localhost:1337/uploads/123456712DHZAUD81UDZQDAZ.png",
"provider": "local",
"provider_metadata": null,
"created_at": "2019-12-09T00:00:00.000Z",
"updated_at": "2019-12-09T00:00:00.000Z"
},
"title": "Amazing photography",
"description": "This is an amazing photography taken..."
}
],
"opening_hours": [
{
"id": 1,
"day_interval": "Tue - Sat",
"opening_hour": "7:30 PM",
"closing_hour": "10:00 PM"
}
]
}
My media host is using JSONP to embed videos. I embed this script, along with a few others, in order to embed videos. My understanding is that it's using JSONP in order to overcome CORS issues.
What I do not understand is the last line of the script.
window['wistiajsonp-/embed/medias/8up1lc9606.jsonp'] = window['wistiajsonp-/embed/medias/8up1lc9606.jsonp'];
window['wistiajsonp-/embed/medias/8up1lc9606.jsonp'] = {
"media": {
"assets": [{
"type": "original",
"slug": "original",
"display_name": "Original file",
"width": 1920,
"height": 1080,
"ext": "mp4",
"size": 109515791,
"bitrate": 16127,
"public": true,
"status": 2,
"progress": 1.0,
"url": "https://embed-ssl.wistia.com/deliveries/9b53a11c8a871733aadd479d26a10d4555de2d66.bin",
"created_at": 1522785172
}, {
"type": "still_image",
"slug": "still_image_1920x1080",
"display_name": "Image",
"width": 1920,
"height": 1080,
"ext": "jpg",
"size": 216848,
"bitrate": 0,
"public": true,
"status": 2,
"progress": 1.0,
"url": "https://embed-ssl.wistia.com/deliveries/bf2cc0bf9de369545df9c9fa8be8371ab8b12f56.bin",
"created_at": 1522785744
}],
"options": {}
};
window['wistiajsonp-/embed/medias/8up1lc9606.jsonp'] = window['wistiajsonp-/embed/medias/8up1lc9606.jsonp'];
(Redacted for the sake of brevity)
Regarding the linked question: I am not talking about Swift; I am talking about JavaScript. Secondly, what I'm asking is directed at the purpose, not the implementation of such "self-assignment".
hoping to use randomuser.me in a prototype i'm putting together (html, css, jquery)
I need to use its api to access profile photos.
I've got this code puling in the JSON as they show in their documentation:
$.ajax({
url: 'https://randomuser.me/api/?results=5&gender=female',
dataType: 'json',
success: function(data) {
console.log(data);
}
});
Now I need to get the url from the picture value in the JSON and write it to the background-image css of a group of divs...I imagine by creating some kind of loop, anybody have an easy to understand way of doing this?
the JSON returned looks like this:
"results": [
{
"gender": "male",
"name": {
"title": "mr",
"first": "romain",
"last": "hoogmoed"
},
"location": {
"street": "1861 jan pieterszoon coenstraat",
"city": "maasdriel",
"state": "zeeland",
"postcode": 69217
},
"email": "romain.hoogmoed#example.com",
"login": {
"username": "lazyduck408",
"password": "jokers",
"salt": "UGtRFz4N",
"md5": "6d83a8c084731ee73eb5f9398b923183",
"sha1": "cb21097d8c430f2716538e365447910d90476f6e",
"sha256": "5a9b09c86195b8d8b01ee219d7d9794e2abb6641a2351850c49c309f1fc204a0"
},
"dob": "1983-07-14 07:29:45",
"registered": "2010-09-24 02:10:42",
"phone": "(656)-976-4980",
"cell": "(065)-247-9303",
"id": {
"name": "BSN",
"value": "04242023"
},
"picture": {
"large": "https://randomuser.me/api/portraits/men/83.jpg",
"medium": "https://randomuser.me/api/portraits/med/men/83.jpg",
"thumbnail": "https://randomuser.me/api/portraits/thumb/men/83.jpg"
},
"nat": "NL"
}
],
"info": {
"seed": "2da87e9305069f1d",
"results": 1,
"page": 1,
"version": "1.1"
}
}
If I've got right you need something like this:
$( ".myDivClass" ).each(function( index ) {
$( this ).attr("background-image", results[index].picture.medium));
});
Or if you have in results only one element of array so to do: ...results[0].picture.medium...
I'm having trouble pulling in the content from my tumblr formatted as JSON. I registered an API key from tumblr, and have the right API link, but am missing something in the $.getJSON. Below I'll show what my JSON and my jQuery both look like.
Here's what my JSON looks like:
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"blog": {
"title": "BLOG TITLE",
"name": "BLOG NAME",
"posts": 96,
"url": "http://BLOGTITLE.tumblr.com/",
"updated": 1370605005,
"description": "BLOG DESCRIPTION",
"ask": false,
"ask_anon": false,
"is_nsfw": false,
"share_likes": true,
"likes": 0
},
"posts": [
{
"blog_name": "BLOG NAME",
"id": 52373434879,
"post_url": "POST URL",
"slug": "POST SLUG",
"type": "photo",
"date": "2013-03-07 11:36:44 GMT",
"timestamp": 1370605004,
"state": "published",
"format": "html",
"reblog_key": "T0m0e51u",
"tags": [],
"short_url": "SHORT URL",
"highlighted": [],
"note_count": 1,
"caption": "PHOTO CAPTION TEXT DESCRIPTION",
"image_permalink": "http://BLOGTITLE.tumblr.com/image/52373434879",
"photos": [
{
"caption": "",
"alt_sizes": [
{
"width": 640,
"height": 960,
"url": "http://31.media.tumblr.com/.../...jpg"
},
{
"width": 500,
"height": 750,
"url": "http://31.media.tumblr.com/.../..._500.jpg"
},
{
"width": 400,
"height": 600,
"url": "http://24.media.tumblr.com/.../..._400.jpg"
},
{
"width": 250,
"height": 375,
"url": "http://31.media.tumblr.com/.../..._250.jpg"
},
{
"width": 100,
"height": 150,
"url": "http://24.media.tumblr.com/.../..._100.jpg"
},
{
"width": 75,
"height": 75,
"url": "http://24.media.tumblr.com/.../..._75sq.jpg"
}
],
"original_size": {
"width": 640,
"height": 960,
"url": "http://31.media.tumblr.com/.../..._1280.jpg"
}
}
]
},
Here's what my jQuery looks like:
jQuery(document).ready(function(){
var url = "http://api.tumblr.com/v2/blog/BLOGNAME.tumblr.com/posts?api_key=APIKEY&limit=5";
var src;
var caption;
$.getJSON(url, function(results){
$.each(results.response, function(i,item){
src = "posts.photos.alt_sizes.url";
caption = posts.caption;
$("<img/>").attr("src", src).appendTo("#submissions").wrap('<div class="postImage"></div>').after('<span class="postCaption">' + caption + '</div>');
});
HTML:
<div id="submissions"></div>
I am pretty sure that the problem is in the $.getJSON or $.each, but I can't figure out exactly what. Any help?
Thanks.
You are probably getting an error because you are trying to access the variable post which is not defined. And you are iterating over results.response, but it looks like you want to iterate over results.response.posts, which is an array of blog posts.
Furthermore, each post seems to have an photos array from which you have to choose the element with photo size you want to have.
Example:
$.each(results.response.posts, function(i, item){
var src = item.photos[0].alt_sizes[0].url; // first picture, first size
var caption = item.caption;
$("<img/>").attr("src", src).appendTo("#submissions").wrap('<div class="postImage"></div>').after('<span class="postCaption">' + caption + '</div>');
});
Of course if a post doesn't have a photo and the array is empty, you will get a runtime error, but I assume you will account for these cases.
The other problem is that you cannot make an Ajax request to the tumblr API since it is an external domain. However, the tumblr API supports JSONP, so if you add &callback=? to the URL, you tell jQuery to use JSONP instead:
var url = "[...]/posts?api_key=APIKEY&limit=5&callback=?";
I recommend to read some basic JavaScript tutorials to learn how to work with arrays and objects:
Eloquent JavaScript - Data structures: Objects and Arrays
MDN - Working with objects
MDN - Predefined Core Objects: Array object