API 값을 요청하면 $results
이 배열을 반환하지만 google은 $results
을 객체로 사용하고 있습니까? 나는 항상Google 애널리틱스 API - PHP 개체 대 배열?
Fatal error: Call to a member function getKind() on a non-object
가 변경나요 라이브러리를 얻고 자신의 예를 더 이상 작동하지 않습니다 https://developers.google.com/analytics/devguides/reporting/realtime/v3/reference/data/realtime/get#examples
, 또는 오류가 내 옆에서있다 :
강령은 아래? 그러나 $ optparams 값을 제외하고는 지금까지 코드를 변경하지 않았습니다.
추신 : 모든 것이 지금까지 진행되고 있습니다. 그것은 단지 객체/배열 문제에 관한 것입니다.
나는 print_r($results)
당 얻을 :
Array (
[kind] => analytics#realtimeData
[id] => https://www.googleapis.com/analytics/v3/data/realtime?ids=ga:**censored**&dimensions=ga:medium&metrics=ga:activeVisitors
[query] => Array (
[ids] => ga:**censored**
[dimensions] => ga:medium
[metrics] => Array (
[0] => ga:activeVisitors
)
[max-results] => 1000
)
[totalResults] => 8
[selfLink] => https://www.googleapis.com/analytics/v3/data/realtime?ids=ga:**censored**&dimensions=ga:medium&metrics=ga:activeVisitors
[profileInfo] => Array (
[profileId] => **censored**
[accountId] => **censored**
[webPropertyId] => **censored**
[internalWebPropertyId] => **censored**
[profileName] => **censored**
[tableId] => realtime:**censored**
)
[columnHeaders] => Array (
[0] => Array (
[name] => rt:medium
[columnType] => DIMENSION
[dataType] => STRING
)
[1] => Array (
[name] => ga:activeVisitors
[columnType] => METRIC
[dataType] => INTEGER
)
)
[totalsForAllResults] => Array (
[ga:activeVisitors] => 752
)
[rows] => Array (
[0] => Array (
[0] => DIRECT [1] => 283
)
[1] => Array (
[0] => E-Mail [1] => 5
)
[2] => Array (
[0] => ORGANIC [1] => 287
)
[3] => Array (
[0] => REFERRAL [1] => 92
)
[4] => Array (
[0] => SOCIAL [1] => 49
)
[5] => Array (
[0] => cpc [1] => 23
)
[6] => Array (
[0] => e-mail [1] => 8
)
[7] => Array (
[0] => facebook [1] => 5
)
)
)
"비 개체에서"는 액세스하려는 개체가 'NULL'임을 의미합니다. 데이터를 다시 가져 오시겠습니까? –
코드는 어디에 있습니까? – thescientist
코드는 URL 아래에 있습니다 (사이트를 폭파하고 싶지는 않습니다). 사용 가능합니다. 예, print_r ($ results)을 사용하면 실시간 값을 얻습니다. – John