【问题标题】:I have an object, but error says I'm making a function call on a non-object我有一个对象,但错误提示我正在对非对象进行函数调用
【发布时间】:2015-11-01 18:31:06
【问题描述】:

我正在使用 Infusionsoft SDK。我在尝试进行一些 API 调用时遇到了障碍。

我拨打的任何电话都以相同的Call to a member function getRefreshToken() on a non-object 错误结束(但并非总是getRefreshToken())。

当我 var_dump 时,我看到它是一个对象。那么,什么给出了?

object(Infusionsoft\Infusionsoft)#182 (13) { ["url":protected]=> string(42) "https://api.infusionsoft.com/crm/xmlrpc/v1" ["auth":protected]=> string(51) "https://signin.infusionsoft.com/app/oauth/authorize" ["tokenUri":protected]=> string(34) "https://api.infusionsoft.com/token" ["clientId":protected]=> string(24) "actual client ID" ["clientSecret":protected]=> string(10) "actual secret key" ["redirectUri":protected]=> string(65) "http://benjamin_redden.dev/wp-content/plugins/ajaxIsForm/auth.php" ["apis":protected]=> array(0) { } ["debug":protected]=> bool(false) ["httpClient":protected]=> NULL ["httpLogAdapter":protected]=> NULL ["serializer":protected]=> NULL ["needsEmptyKey"]=> bool(true) ["token":protected]=> string(24) "actual token" } Fatal error: Call to a member function getRefreshToken() on a non-object in /Users/Krsna/Sites/benjamin_redden/wp-content/plugins/ajaxIsForm/vendor/infusionsoft/php-sdk/src/Infusionsoft/Infusionsoft.php on line 261

这是我从运行类似...的调用中得到的错误

var_dump($infusionsoft); $infusionsoft->refreshAccessToken();

function get_those_ids($infusionsoft){
  var_dump($infusionsoft);
  // get the form IDS
  $formIDS = $infusionsoft->webForms()->getMap();

  // make the dropdown
  echo '<select name="infusionsoft_forms_which_form_would_you_like_to_use_" id="infusionsoft_forms_which_form_would_you_like_to_use_">';
  foreach($formIDS as $formID => $formName){
    echo '<option value="'. $formID .'">'. $formName .'</option>';
  }
  echo '</select>';
}

【问题讨论】:

    标签: php api object infusionsoft


    【解决方案1】:

    想通了!

    我将令牌设置为包含令牌的实际字符串,但显然它宁愿拥有整个对象令牌(包含刷新令牌、重定向 uri、生命周期结束和所有内容)

    所以,它最终变成了 $infusionsoft-&gt;setToken($unserializedToken);

    而不是像$infusionsoft-&gt;setToken($tokenString);这样的东西

    效果很好,直到我尝试将一些信息保存到 WP 中的自定义帖子类型,现在我得到的只是 Guzzle 错误... =(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多