普通网友 2015-01-15 20:40
浏览 114

Pinterest api在被wp_remote_get调用时返回null

Pinterest api works fine in the browser side to show share count for a specific URL as seen here for Google.

But when I try to call it from wp_remote_get function of Wordpress, it returns null:

$url = "http://api.pinterest.com/v1/urls/count.json?url=http://www.google.com";
$response = wp_remote_retrieve_body(wp_remote_get($url, 
    array ('timeout' => 30, 'sslverify' => false ) ) );
var_dump($response); // null

I want to underline that, this function block works fine when I try to get share counts of Google, Facebook or Twitter.

I also tried wp_remote_post, nothing changed with the response.

  • 写回答

1条回答 默认 最新

  • douhang8991 2015-01-15 20:54
    关注

    OK, I found an answer for this problem. The wp_remote_get function returns an array which has a body. But the wp_remote_retrieve_body function can't convert it into a string since it's in the form of a javascript callback (I guess).

    When I get the body directly from the response of the first array and removed the callback function as told here, I got the response json.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分