REMINDER
can we fetch our blog posts with the searchbar discussed in the new docs?
-
-
@David-Alimi said in can we fetch our blog posts with the searchbar discussed in the new docs?:
image = '//cf.appdrag.com/APPID/'+ image
Hi again David thanks a mil for the tut, but I think I am messing up again so I changed image to image url and addec my appid and have saved and published my api key but my images are still not showing. Have doublechecked that my appid is correct and have pasted it where it say APPID in your example. do I need to change the 'image' column in my database as well? perhaps url or something?
var request = require('request'); var cloudbackend = require('appdrag-cloudbackend'); cloudbackend.init(process.env.APIKEY, process.env.APPID); exports.handler = (event, context, callback) => { var options = { 'method': 'POST', 'url': 'https://api.appdrag.com/api.aspx', 'headers': { 'Content-Type': 'application/x-www-form-urlencoded' }, form: { 'command': 'BlogArticlesList', 'appID': process.env.APPID, 'orderBy': 'publishDate' } }; request(options, async function (error, response) { var articles = JSON.parse(response.body).Table for (let i = 0; i < articles.length; i++) { let title = articles[i].title ; let description = articles[i].description; let category = articles[i].category; let author = articles[i].author; let PublishDate = articles[i].PublishDate; let image = articles[i].imageUrl; image = '//cf.appdrag.com/APPID/'+ image var query = "INSERT INTO ArticlesBlog (title, description, image, category, author, PublishDate)"; query += "VALUES ('" + title + "', '" + description + "', '" + image + "','" + author + "','" + category + "', '"+ PublishDate +"')"; await cloudbackend.sqlExecuteRawQuery(query) } callback(null, 'OK') }); } code_text
-
@David-Alimi ok finally got it to work but I could only get it to work after manually saving and publishing my api several times...so this is a manual process, i.e. I cannot get the blogposts to be saved automatically?
-
Hi Linda,
You could try the "Schedule" option on the right side to have it run once per hour, day, etc. in order to keep current
-
@Daniel-Mulroy excellent idea thanks a mil Daniel
-
so now to the search functionality. I noticed that you add the "what" word in your search example, but I don't have just one word I want to target. I want the title and a descriptioin. Does this mean that I have to copy and paste all titles and descriptions so that the search works on my blog posts?
thanks in advance
Linda -
Hi @Linda-MacDonald,
In our example, the user enters the word 'what' in the search bar and we search if it exists only in our titles (and our output is only the title of the article found).
However, you can also search if this word exists either in the title or in the description, and in this case you can select in the output ('title' and 'description')If you want to search only in titles but want to receive the title + description, it's up to you to choose the output columns you want to receive.
Here is an example :
I hope I answer your question well.
Thank you and have a nice day
-
@David-Alimi thanks a mil yes I would like to search in title, description and fetch the feature image...basically want to replicate the search in the ecommerce templates, it's really cool
-
Hello @Linda-MacDonald,
I just modified the article to use the BLOG API with a search bar even more easily only in the front-end.
PS: No need to use the backend anymore
You can find the article here. -
@David-Alimi fantastic
I have been obsessing about search for AGES!! can we analyze our search-results somehow? if we use the database that is? I actually want to understand when people do not find what they are looking for, i.e. when they get 'result not found' and when they use a synonym which isn't in the blog post but would be the same topic. Is that level of analysis possible using appdrag only?