Pinterest的API - 纯JSON响应? [英] Pinterest API - pure json response?
问题描述
所以我做了一个简单的HTTP请求,Pinterest的的API来获取链接的次数:
So I made a simple HTTP request to Pinterest's API to get the count of a link:
$this->load->library('rest');
$this->rest->initialize(array('server' => 'http://api.pinterest.com/'));
$return_data = $this->rest->get('v1/urls/count.json?callback=&url=' . $link);
我得到的回应是:
The response I get is:
receiveCount({"count": 5743, "url": "http://google.com"})
您可以此处自己试用一>
我不希望回调,我试着设置回调=
,但括号仍在present所以无法通过<$ C $解析C> json_de code 。
I don't want the callback and I tried setting callback=
but the parenthesis are still present so I can't parse it via json_decode
.
有没有得到一个纯粹的JSON响应,而无需字符串替换括号自己一个更好的办法?
Is there a better way of getting a pure json response without having to string replace the parenthesis myself?
推荐答案
该Pintrest API目前正在开发并没有准备好供公众使用;他们前一阵子删除自己的文件。然而,有对API的V2在博尔特缓存。
The Pintrest API is currently in development and is not ready for public use; they removed their own documentation a while ago. There is however a cache on Bolt for v2 of the API.
现在我只想做响应一个正则表达式,如
For now I would just do a regex on the response such as
$return_data = preg_replace('/^receiveCount\((.*)\)$/', "\\1", $return_data);
然后 json_de code
这一点。
这篇关于Pinterest的API - 纯JSON响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!