Conversation
Is it possible to call multiple external API calls? I think a second call is needed to get a user's bio or posts. |
@jagtalon No, not yet. I had this same problem with the reddit plugin. |
Thanks, @MithrandirAgain ! |
This is possible, it is just not the most straightforward right now. Within the JS callback you can call another endpoint and have it callback another function. Would the second call have the same format? The other reason we don't like to do it is because it ends up being significantly slower. One hybrid approach is to do the alternative-to type setup and then have the clicks do a re-query on DDG that triggers a second plugin that displays the bio information. Does that make sense? |
Hi, @yegg. I think the hybrid approach is a great idea. The user could click on the user's profile (http://i.imgur.com/5big2.png) and it sends another query to DuckDuckGo to display the user's bio information. Would it still work if it had a different format? The XKCD plugin looks very similar to this description so I'll try imitating that. Thanks for the tip! |
Not sure what you mean by a different format. The Twitter plugin you mentioned is another good one to look at is it has bio information and picture. |
I have a bit of a problem and I'm not really sure what's happening. Everything is fine when I call the API that searches for Google+ users. Here is an example call that the handler makes:
But it doesn't work when I change the spice handler function to call something else (I wanted the user's bio) and I think it's because an error occurs in duckpan. The handler calls:
and a bunch of error messages appear in the terminal like Body must be bytes and should not contain wide characters. I couldn't check spice.js for errors because my Here's the error message. It's a bit lengthy so I did my best to highlight the important things. I tried the debugging tips on duckduckhack but they don't seem to work. Can anyone help me on this? Thanks! |
Update: Whenever I call spice to => 'https://www.googleapis.com/plus/v1/people?query=$1&key={{ENV{DDG_SPICE_RANDWORD_APIKEY}}}&callback={{callback}}'; the API callback is // API callback
ddg_spice_google_plus({
"kind": "plus#peopleFeed",
"etag": "\"hwUd3NZiCApZB9vzwRg6mpj9rZg/MjMV7G73OPlpoksnGiXoxr91Y1A\"",
"selfLink": "https://www.googleapis.com/plus/v1/people?query=udacity&maxResults=10",
"title": "Plus People Search Feed",
"nextPageToken": "EAoaAA",
"items": [ ... which is fine. Then I change it to spice to => 'https://www.googleapis.com/plus/v1/people/$1?key={{ENV{DDG_SPICE_RANDWORD_APIKEY}}}&callback={{callback}}'; and call Hope this helps! |
It works now! Sorry for the long comments but I think I know what happened. I first tried it on the profiles of Steve Martin and Udacity and it turns out that their profiles have UTF-8 strings in it (I wish I saw that earlier). Here's an example:
But it totally worked on my Google+ profile! It's a limitation but I'll try finishing the plugin anyway. |
Why is UTF8 breaking it though? |
I'm not sure. Duckpan shows this error. It happens when I get strings like
from the API. What can I do to fix this? |
@yegg it's an issue with duckpan -- I already made the issue, just forgot to say so here. @Getty assures me that he knows what's wrong. |
@hunterlang that's good 😃. I think the plugin works pretty well as long as people don't search for foreign names. |
@jagtalon Hey, thanks a lot for the plugin, I've been playing around/testing it out and everything seems pretty good. Regarding a few things I've noticed though: GooglePlus.pm:
Spice.js:
if (google["items"].length > 5) {
limit = 5
} else {
limit = google["items"].length
} you could also use a ternary if you want it all in one line I suppose.
var query = DDG.get_query();
items[0]['h'] = 'Google+ Users (' + query + ')'; DDG.get_query is a new global function which, well gets the query.
Other than those few small things the plugin is totally awesome! I hope I don't sound too demanding, let me know what you think and we can go from there. |
@moollaza It's done! Although I'm having trouble with var query = DDG.get_query();
items[0]['h'] = 'Google+ Users (' + query + ')'; because it only returns Thanks for the awesome comments! |
@jagtalon Thanks a lot! |
@moollaza Thanks! I just have to create a regexp that removes the trigger words from the query. Oh, I tried searching google+ google+ and it doesn't hit any plugins. What could be the problem? |
@jagtalon that looks awesome! I'll play around with it some more and then hopefully I can get it deployed today. Thanks again for all your work! |
@jagtalon Hey, I found a small bug, your regex check for cleaning up the user's url's is actually case sensitive (search "google+ userid:115868784569078797995" ) So, to make it non case-sensitive you need to add and "i" after the last slash in the regex:
on that note, because in this example the whole url is ALL CAPS, I think we should first EDIT: Also, I think we should maybe strip out ".com" |
@moollaza Whoa, I assumed that the links returned are already in lowercase. The links displayed by this profile |
@jagtalon Alright its on GitHub and ready to go live, should be deployed some time soon Thanks again for all the great work! |
@jagtalon hey, we found a bunch more bugs/visual things I somehow failed to notice:
|
@moollaza Google returns this value |
@jagtalon you're right (\w*) will pass wasn't thinking correctly. Possible section, they were wondering if there was more data that could be displayed - I noticed Google gives us relationship status and placed lived -- perhaps we should show those? Also I think I noticed that your code will display both the tagline and intro if the tagline is present. It should only show the intro if there is no tagline. Thanks! |
@moollaza Oh, I was thinking of minimizing the space that it occupies but I'll add it if you guys want. Is this the code? Is it having problems with some users? if (google.tagline) {
out += '<div class="google_profile"><i>Introduction: </i> ' + google.tagline + '</div>';
} else if(google.aboutMe) {
out += '<div class="google_profile"><i>Introduction: </i> ' + google.aboutMe.substring(0, 200);
if(google.aboutMe.length > 200) {
out += '...' + '</div>';
} else {
out += '</div>';
}
} Thanks! Sorry for the numerous bugs in my ZCI! Edit: |
@jagtalon never mind what I said about the "else if" statement -- I'm just crazy. Regarding the multiple links: yes its good to keep them if the url's aren't identical. For some reason my profile had two links to my YouTube channel which were the same. |
@moollaza I added just the current place the person is currently living in. What about profiles without a tagline, aboutMe, placesLived? Should I just say "This person has nothing to share with the public."? |
@jagtalon I dont think so, lets just display what they have and not mention what they don't. Also the current location is great, we can leave relationship status out. |
@moollaza Okay thanks! I just pushed my changes and it should look a lot better than it used to. |
@jagtalon just noticed you fixed the Introduction bug, but it still displays "Introduction:" with just a blank beside it -- can you remove it when there's nothing to display? |
@moollaza I'm not sure if I have to close it or not because it still returns something ( |
@jagtalon that should work |
@moollaza Done! Thanks again! |
@jagtalon thanks a lot, it should be live soon -- I found you twitter handle so you'll get a mention when we tweet it out :) Thanks again! |
@moollaza Cool, thanks for all your help! |
@moollaza What if we imitate the shortened links on Hacker News (only remove the http://www and the /)? The current plugin works for things like facebook.com (Facebook) or github.com (Github) but not bbc.com (Bbc) or cnn.com (Cnn). |
@jagtalon sure thing, I think they just force lower case and then strip accordingly. |
@jagtalon btw if you want to make any new changes please make it in a new pull request -- this thread is getting a little long! |
@moollaza Just made a new pull request, thanks! |
Uses Google's API to search for people on Google+. It has the same format as the Alternative to plug-in. I'm not sure but it could be better if it had some bio and the most recent post like the Twitter plugin.
https://duckduckhack.uservoice.com/forums/5168-plugins/suggestions/2871127-google-integration