bug^君 2017-03-18 10:16 采纳率: 25%
浏览 31

Facebook使用ajax计数

I have a problem with getting number of shares of my custom url. Im trying this code:

$.ajax({
    type: "POST",
    url: "http://graph.facebook.com/https://www.myurl.com/somelink/?callback=?",
    processData: true,
    contentType: 'application/json',
    success: function(r){
      var fbjson = JSON.stringify(r);
      console.log(fbjson);
    }
  });

I've tried also:

$.getJSON('http://graph.facebook.com/https://www.myurl.com/somelink/?cal‌​lback=?'), function (data) {

fbjson = JSON.stringify(fbjson);

console.log(fbjson);


 };

When I paste url into browser I recieving JSON with all needed information, but when I am using $.ajax etc. I am recieving totaly different json or some error that I should use XMLHttpRequest or some other serwer status information. Important knowladge may be that I am using https://.

Anyone know how to correctly get FB share count for custom URL ?

PS Be understanding for me, this are my first steps in JS, thanks :)

  • 写回答

2条回答 默认 最新

  • 撒拉嘿哟木头 2017-03-18 10:21
    关注

    For the json might be cooke issue. your browser have cookie for that URL but in ajax you need to pass that cookie !

    Why you are counting share count manually ? There is lots of share tools is available for fee !

    example : http://js-socials.com/

    I think this plugin will give you what you need !

    Thanks

    评论

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算