Assurez-vous que "Onebox Assistant" explore ces aperçus de manière fiable !

Ce qu’il fait

Transforme ce type de résultat :

(où votre serveur n’a pas réussi à récupérer le code source de la page et ne peut donc pas extraire les balises requises pour créer la onebox)

En ceci ! :

Il fournit simplement un chemin alternatif pour que la onebox puisse obtenir son code source de page afin de rechercher des métadonnées lorsque le serveur cible refuse votre connexion.

Il ne modifie en rien la façon dont la onebox traite ensuite le code source de la page pour trouver les métadonnées et afficher la boîte.

Il est conçu pour vous permettre de saisir les détails et les informations d’identification d’une API tierce afin de récupérer la page au lieu d’effectuer un appel HTTP normal directement vers la page cible.

Pourquoi

J’ai constaté que mes serveurs se voyaient refuser l’accès à un certain nombre de sites commerciaux, ce qui empêchait le rendu des oneboxes. Cela aide essentiellement à tirer parti de la fiabilité de l’API tierce, un peu comme un service de messagerie.

Pourquoi c’est rentable

Vous pouvez utiliser un VPS relativement peu coûteux tout en bénéficiant d’une fonctionnalité de onebox fiable, même si votre adresse IP ou votre agent utilisateur est en quelque sorte « blacklisté ».

Vous n’en avez pas besoin si

Vous générez correctement toutes vos cibles de contenu avec l’installation standard et tous les utilisateurs sont satisfaits.

Prérequis

Vous devez disposer d’un compte auprès d’une API tierce appropriée.

Paramètres

onebox assistant api base address:  https://api.embed.rocks/api/

L’exemple ci-dessus utilise embed.rocks, mais à l’avenir, la prise en charge d’autres API pourrait être ajoutée. Cependant, embed.rocks offre actuellement un bon rapport qualité-prix.

onebox assistant api base query:   ?url=

onebox assistant api options:   &skip=article,description,oembed,imextra&include=source

onebox assistant api page source field:   source

Vous devrez également saisir votre clé API fournie par embed.rocks.

Voir l’exemple ci-dessous

Ce paramètre vous permet d’ignorer la prérecherche (pour vérifier si le crawl direct retourne un résultat) et d’utiliser l’API dès le départ.

image
par défaut DÉSACTIVÉ

Je recommande de définir ce paramètre sur VRAI.

Bien sûr, cela est plus coûteux, mais donne souvent de meilleurs résultats, car il existe des cas où la prérecherche est redirigée vers la mauvaise page parce que vous n’êtes pas considéré comme fiable.

Informations de support

Rappelez-vous, si vous avez déjà tenté de créer une onebox pour un lien, le noyau Discourse mettra en cache le résultat.

Vous pouvez ajouter une chaîne de requête aléatoire à la fin pour contourner le cache : https://mylink.com/todaynews?random=random

Vous pouvez également vérifier que l’API répond avec, par exemple :

curl -X GET "https://api.embed.rocks/api/?url=https%3A%2F%2Fnews.bbc.co.uk%0A&skip=article,description,oembed,imextra&include=source" -H "x-api-key: %%%votre-clé-api%%%"

Vous devez encoder en URL le site que vous appelez (la valeur du paramètre url) en utilisant un site comme celui-ci (non garanti !).

Limitations connues

  • Il a été testé uniquement avec un fournisseur pour le moment et n’a pas été testé sur d’autres. Ce fournisseur est https://embed.rocks (avec qui je n’ai aucune affiliation). Je suis prêt à envisager de prendre en charge davantage de services si le travail est parrainé.

  • Le monkey patching est effectué au niveau de la méthode. Cela remplace plus de code que nécessaire, ce qui augmente le risque que le plugin se brise après une mise à jour du noyau. Cependant, je ne pense pas qu’il y ait un moyen de minimiser cela davantage ?

Comment installer les plugins

Consultez le guide ici : Install plugins on a self-hosted site

Ce dépôt est : https://github.com/merefield/discourse-onebox-assistant

https://github.com/merefield/discourse-onebox-assistant

Tous les retours sont les bienvenus. Veuillez mettre une :étoile: sur GitHub si vous le trouvez utile.

41 « J'aime »

Sorry I haven’t had a chance to rebuild our site with this addon enabled, I’ll do so tonight.

@WaitroseCarpark I didn’t fill out anything like that, steps I followed are:

Step 1:

Step 2:

Step 3:

Step 4:
do the robot check

Step 5:
add oEmbed api


sign your life away
image
green tick for oEmbed
image

Step 6:
get creds from Settings > Basic

Step 7:
get an app token

with the creds from above, run

curl -X GET "https://graph.facebook.com/oauth/access_token?client_id={your-app-id}&client_secret={your-app-secret}&grant_type=client_credentials"

which returns

{"access_token":"378384926723309|xxxxxx","token_type":"bearer"}

test your auth token

curl -X GET \ "https://graph.facebook.com/v9.0/instagram_oembed?url=https://www.instagram.com/p/fA9uwTtkSN/&access_token=xxxx..."

which returns

{"version":"1.0","author_name":"diegoquinteiro","provider_name":"Instagram","provider_url":"https:\/\/www.instagram.com\/","type":"rich","width":658,"html":"\u003Cblockquote class=\"instagram-media\" data-instgrm-captioned data-instgrm-permalink=\"https:\/\/www.instagram.com\/p\/fA9uwTtkSN\/?utm_source=ig_embed&utm_campaign=loading\" ....

Add to discourse and you’re done!

6 « J'aime »

Wow…

Ok, that worked…

Thanks man :bowing_man:

4 « J'aime »

With the plugin installed? @Richie

1 « J'aime »

@znedw Thank you so much for taking the time to explain step by step (with pictures! :heart_eyes:) how to do this! Works a charm as far as I can see!

3 « J'aime »

with the plugin installed?

1 « J'aime »

I only actually noticed you’ve made this plugin just now…I was not using it, sorry for hijacking your thread.

BUT, I will try it out later today if I can find some spare time…

2 « J'aime »

I spent half an hour or so this evening trying all manner of possible permutations, Robert @merefield

Following the steps provided by @znedw (thanks again my man!) it would appear that this method works both with the Onebox Assistant enabled, and with it disabled too (via admin panel, plugins, checkbox).

I’ve not tried rebuilding my Discourse with the plugin completely removed.

Perhaps worth a note, I do not have the option enabled for “Always use the proxy crawl regardless of direct response”.

Off topic, it would appear amazon.co.uk are blocking all manner of requests again, both directly (plugin disabled) and also via embed.rocks “try it” page, which also times out :roll_eyes:

3 « J'aime »

Thanks. Yes I expected it to work at least without the “always use the proxy”

2 « J'aime »

On the subject of Amazon I always use their affiliate links anyway, manually, which are not blocked.

Oneboxing breaches their T&Cs if you are an affiliate.

Highly recommend you consider the affiliate membership. It doesn’t net a fortune but may pay for the server and mail fees.

1 « J'aime »

Is it possible to use this plugin only for YouTube links? Can’t understand what settings should I use for this.
And also where can I find more info about possible settings?
Thank you!

No. You’d have to fork and develop the code further.

Just copy those in the OP exactly. You will have your own key.

2 « J'aime »

How can I check if the plugin working and the queries are going through https://embed.rocks?
I activated it, but the error hasn’t gone.

I test with these videos:

https://www.youtube.com/watch?v=_2wfBNUnOVY
https://www.youtube.com/watch?v=qLNhVC296YI
1 « J'aime »

The dashboard on embed.rocks should start reflecting your calls (a local counter is a nice-to-have but have not yet implemented one)

Both of those links work for me via the plugin.

If it’s not working, try checking this option:

image

2 « J'aime »

Are all settings you have equal to those in the picture you gave? Maybe I have a mistake when typing them. Any option to copy them?

1 « J'aime »

I’ve added plaintext to the OP for you.

3 « J'aime »

Thank you. I checked and everything was correct. I can’t see any call on the Dashboard page in the Usage section. Does it mean smth is wrong? Should the number of calls always be visible?

1 « J'aime »

You’d need to ask embed.rocks that question. At some point I may add additional logging to the plugin which might help. You might be able to set your site to log level ‘info’ to get more information however, as there are existing calls to Rails.logger.info

1 « J'aime »

Yeah, that would be great. Because now I activated the plugin and configured the settings, but youtube is not working and there is no activity on the Dashboard. I sent an email to the embed.rocks support.

1 « J'aime »

Will this plugin work correctly if I store files at Amazon S3?
I still struggle with it and can’t make it working. Videos are not uploaded - only links. And there is no information on the Usage Panel of the Embed.rocks

I have a testing server. Files are stored locally on it. But the plugin also doesn’t work and there is no activity on the Usage dashboard. But videos are saved on the site.

So I can’t understand how and what to check to solve the problem.

Please, help with your ideas.

2 « J'aime »