flickr / flickr-sdk Goto Github PK
View Code? Open in Web Editor NEWAlmost certainly the best Flickr API client in the world for node and the browser
Home Page: https://www.flickr.com/services/api
License: MIT License
Almost certainly the best Flickr API client in the world for node and the browser
Home Page: https://www.flickr.com/services/api
License: MIT License
This is a suggestion for the API itself, rather than this node client, but it would be good to be able to set the license for an image in the upload.
So here: https://www.flickr.com/services/api/upload.api.html
...it would be good to have a license_id argument, matching obviously with ids from flickr.photos.licenses.getInfo.
I'm trying ./examples/oauth.js
I get the flickr page, and after I click [OK, I'LL AUTHORIZE IT]
, I get a "Secure Connection Failed" page
Any hint?
Secure Connection Failed
An error occurred during a connection to localhost:3000. PR_END_OF_FILE_ERROR
The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.
Doing a request with the SDK from the browser doesn't work any more. The CORS preflight OPTIONS
request fails with the following error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.flickr.com/services/rest?method=flickr.photosets.getPhotos&[...]. (Reason: header ‘user-agent’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response).
The response to the CORS preflight request has the header access-control-allow-origin
set to *
, which is good, but it also requests that there is an access-control-allow-headers
set to user-agent
.
This is a bug I noticed only now, but I believe was introduced with #156.
I didn't notice before because I was doing the requests from a server-side rendered home page. So it was only visible when initially loading another page of my website and then going to the home page.
I'm not sure that adding the header access-control-allow-headers
to the CORS response is the solution. It is actually not really appropriate that the request is sent from the browser with a custom user-agent
header. It should be sent with the browser user-agent
value. So ideally, the custom user-agent
header should be set only when requests are sent from the server-side.
As, in the end, it will not be mandatory any more to provide a user-agent
to call the Flickr API, then maybe the simplest solution is to revert dc79a7a?
Hi guys,
I think the sdk could be improved as follows:
If we already have:
var flickr = new Flickr(Flickr.OAuth.createPlugin(
process.env.FLICKR_CONSUMER_KEY,
process.env.FLICKR_CONSUMER_SECRET,
process.env.FLICKR_OAUTH_TOKEN,
process.env.FLICKR_OAUTH_TOKEN_SECRET
));
... then why not just await flickr.upload(file, [args])
rather than having to call a constructor again?
It feels like this would be more intuitive. I've got a module where I create flickr
and then I import it wherever I need it. But currently for upload, I have to create the auth function again, call a constructor, and await the resulting promise.
Great library though, I got up and running with the API very quickly.
Cheers,
Ian
Can you add the Opt in opt out in this request https://www.flickr.com/services/api/flickr.people.getGroups.html ?
I find very annoying ( for me and for you ) having to do another request for each group I want to know if they are opted out.
You could add it in the extras
I'll be very happy about it.
I'm attempting to update a photoset with several hundred photos in it, and hitting a 413 response (request too large). Here's what I'm doing:
flickr.photosets.editPhotos({
photoset_id: albumId,
photo_ids: photoIds.join(','), // Several hundred IDs in this array
primary_photo_id: primaryPhotoId
})
I can see from the error response that the bit long set of photo IDs is being passed as a query string param, despite the method being POST
:
https://api.flickr.com/services/rest?method=flickr.photosets.editPhotos&photoset_id=72157720077649915&photo_ids=51545392449%2C51545579665%2C51544622751%2C51545369594%2C51545330174...
Is there any way to coerce the library to send the parameters of this method as a post body rather than as a query string? I couldn't see anything obvious in the documentation, but it looks as though the Flickr API itself should support this in principle.
Hello,
I saw thanks to another issue posted here that the flickr api docs are a bit outdated. I'd like to know what params we can use in https://www.flickr.com/services/api/flickr.groups.search.html
I'm trying to get the throttle from the groups. Is it possible or I have to join the group to get that from https://www.flickr.com/services/api/flickr.people.getGroups.html
Thanks
flickrapi
has options for passing and API key + secret eg. https://github.com/Pomax/node-flickrapi#no-authentication-public-api-only but the README for flickr-sdk doesn't show how to do this, it would be helpful to see an example of how to do this with flickr-sdk.
Hello,
I run into random issues with the api.
Error: connect ECONNREFUSED {ip}:443
Do you know where I can get more information or some contact to solve it?
Thanks
Is there a call to get all groups from a photo?? I don't find it.
When passing a Buffer of a jpg or png file to Upload, xml2js fails to parse the API response and the following error is thrown:
Non-whitespace before first tag.
Line: 0
Column: 1
Char: o
SyntaxError: Non-whitespace before first tag.
Line: 0
Column: 1
Char: o
at /home/user/www/webapp/node_modules/flickr-sdk/plugins/xml.js:39:15
at Parser.<anonymous> (/home/user/www/webapp/node_modules/xml2js/lib/parser.js:308:18)
at Parser.emit (events.js:198:13)
at SAXParser.onerror (/home/user/www/webapp/node_modules/xml2js/lib/parser.js:123:26)
at emit (/home/user/www/webapp/node_modules/sax/lib/sax.js:624:35)
at error (/home/user/www/webapp/node_modules/sax/lib/sax.js:653:5)
at strictFail (/home/user/www/webapp/node_modules/sax/lib/sax.js:677:7)
at beginWhiteSpace (/home/user/www/webapp/node_modules/sax/lib/sax.js:951:7)
at SAXParser.write (/home/user/www/webapp/node_modules/sax/lib/sax.js:1006:11)
at Parser.exports.Parser.Parser.parseString (/home/user/www/webapp/node_modules/xml2js/lib/parser.js:323:31)
at Parser.parseString (/home/user/www/webapp/node_modules/xml2js/lib/parser.js:5:59)
at Object.exports.parseString (/home/user/www/webapp/node_modules/xml2js/lib/parser.js:369:19)
at IncomingMessage.<anonymous> (/home/user/www/webapp/node_modules/flickr-sdk/plugins/xml.js:31:10)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Call to Upload from my code:
async uploadPhoto (user, buffer) {
try {
if (_.isEmpty(user.flickrAuth)) {
return;
}
await new Flickr.Upload(
this.oauth.plugin(user.flickrAuth.token, user.flickrAuth.secret),
buffer,
{ is_public: 1 },
);
} catch (err) {
pino.error('Unable to upload user photo');
throw err;
}
}
I'm using the multer
and sharp
libraries to handle uploading and transformation of user photos. The Buffers are successfully uploading to a cloud storage provider, so I can confirm that they're correct. I'm also successfully completing OAuth and retrieving user photos, so the this.oauth
object is valid.
We are receiving a an error in install the package:
node_modules/xml2js
flickr-sdk >=3.1.0
Depends on vulnerable versions of xml2js
node_modules/flickr-sdk
Please upgrade the flickr-sdk dependency to 0.5.0
Thanks!!
TS is having some issues when trying to location the TS definitions, if I change your package.json file's exports field to this, it works:
"exports": {
".": {
"import": { "default": "./dist/index.mjs", "types": "./dist/index.d.ts" },
"require": { "default": "./dist/index.cjs", "types": "./dist/index.d.ts" }
},
"./package.json": "./package.json"
},
I'm wanting to make requests to Flickr's api in a Cloudflare Worker, but it provides WebCrypto rather than node's crypto implementation.
This turns out to be causing a real headache especially as the WebCrypto API is asynchronous.
Any pointers gratefully received!
There is a missing single quote here: https://github.com/flickr/flickr-sdk/blob/main/script/build-types.ejs#L2
Issue added in 6.2
I'm having this issue in my build:
example-app:build: ../node_modules/flickr-sdk/flickr-sdk.d.ts:2:43
example-app:build: Type error: Unterminated string literal.
example-app:build:
example-app:build: 1 | import type { Request } from './lib/request';
example-app:build: > 2 | import type { Response } from 'superagent;
example-app:build: | ^
example-app:build: 3 | import type OAuth from './services/oauth';
example-app:build: 4 | import type Feeds from './services/feeds';
example-app:build: 5 | import type Upload from './services/upload';
Rollbacking to 6.1.2, latest working version in ts context.
Hello,
I need the total amount of groups a photo belongs to. Right now through the api I have to call photos.getAllContexts
and do a count on the pool array. That's overkill when you already have a get totals with the amount that is being used on the website but not on specified on the api.
photos.getAllContexts {
photo_id: '***',
per_type_limit: 6,
get_totals: 1,
get_all_galleries: 1,
no_faves_context: 1,
primary_photo_extras: 'url_sq, url_t, url_s, url_m, needs_interstitial',
extras: 'can_addmeta,can_comment,can_download,can_print,can_share,contact,content_type,count_comments,count_faves,count_views,date_taken,date_upload,description,icon_urls_deep,isfavorite,ispro,license,media,needs_interstitial,owner_name,owner_datecreate,path_alias,perm_print,realname,rotation,safety_level,secret_k,secret_h,url_sq,url_q,url_t,url_s,url_n,url_w,url_m,url_z,url_c,url_l,url_h,url_k,url_3k,url_4k,url_f,url_5k,url_6k,url_o,visibility,visibility_source,o_dims,publiceditability,system_moderation,datecreate,date_activity,eighteenplus,invitation_only,needs_interstitial,non_members_privacy,pool_pending_count,privacy,member_pending_count,icon_urls,date_activity_detail,muted,owner_name,path_alias,realname,sizes,url_sq,url_q,url_t,url_s,url_n,url_w,url_m,url_z,url_c,url_l,url_h,url_k,url_3k,url_4k,url_5k,url_6k,needs_interstitial'
}
I don't need the extras ( may come in handy in the future ) but I would like to be able to use the get_totals
and per_type_limit
so I can get a fast response. What do you think @jeremyruppel @alex-seville ??
When performing a file upload, the additional parameters don't seem to be sent. The file uploads correctly, but no additional information (e.g. title
, tags
, etc ) gets through. I'm running on Node 6
flickr
.request( token, secret )
.media()
.post( {
photo: "path/to/file.jpg",
title: "My title",
description: "Custom description",
tags: "beach sun"
} )
After adding .unset('X-Flickr-API-Method') I got the following error:
Error: Parser is unable to parse the response
I've reviwed the code and the error occurs on line 6220 from flickr-sdk.js
when using the authentication methods on the sdk object I always get invalid_signature returned. I have tried other packages and they work to confirm my api key and secret work. Can you confirm that latest version does authenticate and there is not a bug somewhere in the hashing of the base string.
Hello,
I have tried to subscribe to a topic but I kept getting this response
Callback failed or invalid response: 504
The call I'm doing is:
https://www.flickr.com/services/rest/?method=flickr.push.subscribe&api_key=5e7e5cc502499cc4a4b931ea904a9ae5&topic=my_photos&callback=https%3A%2F%2Fq2gughvxt6.execute-api.eu-west-1.amazonaws.com%2Fpr13%2Fnotifications%2Fphoto-tags%3FuserId%3Denricu5&verify=sync&verify_token=MYTOKEN&format=json&nojsoncallback=1&auth_token=AUTH_TOKEN&api_sig=SIGNATURE
I don't see any calls nor logs from Flickr I only see my tests to check the url. The link in the description is about the PubSub is broken and I have only found little information.
https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.3.html#subscribing
http://laughingmeme.org/2011/07/24/getting-started-with-flickr-real-time-apis-in-php/
Can you share a sample call from flickr to the subscriber? Is there anything wrong?
I'm getting a warning "A custom superagent parser has been set but buffering strategy hasn't been configured. Call req.buffer(true of false)
or set superagent.buffer[mime] = true or false
" when doing file uploads. I think this needs to happen in the Upload constructor.
Ampersands in descriptions (and possibly elsewhere) appear as &amp;
in the Flickr API. It presumably should be &
.
Not sure this is the right place to report this, but closest I could find.
Hi,
I'm trying to get contacts of the user authenticated, but I have not found any function related how to get them. Is there any way to get them? The user is authenticated using token, and token secret.
Best to all
In light of the announcement to require a user-agent for requests made to the Flickr API, it would be good to ensure that a user-agent header is set by the Flickr SDK, for situations when it used server-side, from a Node.js process.
The Flickr SDK uses superagent v6.1.0, which, from the look of this test, doesn't set a user-agent by default (and it's still not the case in the latest version).
Is it planned to make that change? Searching in the code base, I can only find TODOs about user-agent, but nothing else.
I'm getting a message 'Content not allowed' with status code 8 from pools.add.
Can you elaborate on whats happening? It's not in the docs https://www.flickr.com/services/api/flickr.groups.pools.add.html
Would you recomend caching queries? I asume that is not posible with this sdk.
Hi
I'm using the api to reorder a (very) large amount of photos. So far so good, but I can't find the api call to add an album to an existing collection.
What is the correct api call for that ?
Thanks!
Mark
Is there a way to get the list of groups that a user belongs but with pagination? I'm trying with a user that has a lot of groups and the queries return a Gateway Timout.
Any idea @superic @jeremyruppel ??
It'd be nice to have a method to check if the SDK has been correctly instantiated.
Related Flickr API endpoint : https://www.flickr.com/services/api/flickr.test.echo.html
Do you know why im getting this error? please help!
I am using WebPack.
Here is the code:
const Flickr = require('flickr-sdk/flickr-sdk.js');
const {ipcRenderer, remote} = require('electron');
const oauth = new Flickr.OAuth(
remote.process.env.FLICKR_CONSUMER_KEY,
remote.process.env.FLICKR_CONSUMER_SECRET
);
Is there any hidden way ( I know there hidden stuff on Flickr ) to limit the reslts for that query?
https://www.flickr.com/services/api/explore/flickr.people.getGroups
Some perPage and page params would be appreciated.
For example:
flickr.request().media().search(term).get({
per_page: 10
}).then(response => {
console.log(response);
});
Will result in: Param per_page with type integer not of the expected type: number
While using the api method https://www.flickr.com/services/api/flickr.photos.comments.editComment.html I get intermitent Code 99 Insufficient permissions . When I try it myself it does not fail.
I haven't figured what's going on as the fails seem totally random from me. Any hints @alex-seville ?
I run:
npm install flickr --save
Execute:
var Flickr = require("flickr");
var flickr = new Flickr({
"apiKey": "xxx",
"apiSecret": "yyy"
});
// => TypeError: Flickr is not a constructor
I think this file https://github.com/flickr/flickr/blob/master/index.js should have content:
module.exports = require("flickr-sdk");
Again this is about the API rather than the javascript client, but it would be great to be able to limit searches to particular albums. The API call just needs a photoset_id parameter.
Hello,
Is there a way to consume the api at web browser level with the auhtentication with this SDK?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.