我想检索我帖子的facebook点赞。我已经写了代码,但它显示错误。
facebookDataUrl = "http://graph.facebook.com/yourstory.com/2016/04/shotpitch-startup-trended-product-hunt/"
console.log facebookDataUrl
data = Http::curl(facebookDataUrl)
fbshares = json_decode(data, true)
fbsharescnt = fbshares['shares']
console.log fbsharescnt
上面的代码显示错误
fbshares = json_decode(data, true);
^
ReferenceError:json_decode未定义
使用JSON.parse()
。
get = require 'http-get-shim'
url = 'http://graph.facebook.com/yourstory.com/2016/04/shotpitch-startup-trended-product-hunt/'
get url, (er, resp, body) ->
data = JSON.parse body
console.log data