Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

505
Views
Obteniendo un error de CORS al usar la API de gráficos de Facebook

Utilicé la API de comentarios en vivo de Facebook para recuperar comentarios de video en vivo. Pude hacerlo con éxito en el entorno local. Pero cuando implemento el proyecto con nombre de dominio, aparece el error cors. ¿Alguna idea sobre cómo resolver esto?

Aquí está el código de ejemplo.

 window.Vue = require('vue').default var app = new Vue({ el: '#fb_call', components: { }, data() { return { comments: [] } }, created() { this.getLiveComment() }, mounted() { }, methods: { getLiveComment: function() { let self = this let videoID = '357160146189320' var source = new EventSource("https://streaming-graph.facebook.com/"+videoID+"/live_comments?fields=from{name,id},message&comment_rate=one_per_two_seconds&access_token=xxx"); source.onmessage = function(event) { let keystring = ['lock', 'beli']; let msg = JSON.parse(event.data).message if(keystring.map((kt) => msg.includes(kt)).includes(true)) { self.comments.unshift(JSON.parse(event.data)) } console.log(JSON.parse(event.data).message) }; } } })

Error del navegador

Se ha bloqueado el acceso al recurso en 'https://streaming-graph.facebook.com/357160146189320/live_comments?fields=from{name,id},message&comment_rate=one_per_two_seconds&access_token=xxx' desde el origen 'https://example.com' por política de CORS: no hay ningún encabezado 'Access-Control-Allow-Origin' en el recurso solicitado.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Asegúrese de que el token de acceso no haya caducado. Eso me pasó y el token de acceso a FB estaba vencido. Puede comprobar si el token ha caducado o no mediante la depuración aquí https://developers.facebook.com/tools/debug/accesstoken/

about 4 years ago · Juan Pablo Isaza Report

0

Recibí el mismo error. al usar https://streaming-graph.facebook.com/"+videoID+"/live_comments . Ocurre cuando el video en vivo no se transmite. Devuelve valor cuando su video en vivo se está transmitiendo.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!