php - "Target feed is read-only" in Google Analytics API using PEAR HTTP_Request2 -


I am trying to bring all profiles for some Google Analytics account into PHP I am using HTTP_Request2 class from PR (with curl adapters, but I have also tried with socket) and when I try to get data I get the "target feed read only" error

I 'using the client login authentication method and as far as I can see the correct authority header, each API is sent with the request (I can test for the header Being sent that used observer class).

Here's the code I use (stripped-down, trial version):

  Expected 'HTTP / Request2.php'; Class GA {secure $ email; Protected $ passwd; Protected $ auth_code; Public function __ composition ($ email = '', $ passwd = '') {$ this- & gt; Email = $ email; $ This- & gt; Passwd = $ passwd; } Authorize Public Function ($ email = '', $ password = '', $ force = false) {If (! $ Force and empty ($ this- & gt; auth_code) and $ email == $ this- & gt; ; Email and $ password == $ this-> passwd) {Back to true; } Unset ($ this-> auth_code); Below ($ email) or $ email = $ this- & gt; E-mail; Empty ($ password) or $ password = $ this- & gt; Passwd; If (empty ($ email) or empty ($ password)) {return false; } {$ Response = $ this- & gt; Post ('https://www.google.com/accounts/ClientLogin', Array ('accountType' = & gt; 'GOOGLE', 'email' = & gt; $ this- & gt; Email = $ email, ' Passwd '=> $ this-> passwd = $ password,' service '=>' analytics')); If ($ response-> GetStatus () == 200 and preg_match ('/ (?: ^ | [\ N \ r]) AUTH = (. *?) (?: [\ N \ r] | $) /' , $ Reaction-> getBody (), $ match)) {$ this- & gt; Auth_code = $ match [1]; Sampling $ this- & gt; Auth_code; Back true; }} Hold (HTTP_Request2_Exception $ e) {return false; }} Public function call ($ url, array $ params = array (), array $ headers = array ()) {if (! $ This- & gt; auth_code & amp; amp;! $ This- & gt; Authorize ($ This-> email, $ this- & pass; passwd, true)) {return false; } $ Header ['authorization'] = 'GoogleLogin auth =' $ this- & gt; AUTH_CODE; Return $ - this- & gt; Post ($ url, $ params, $ headers); } Secure Function Posts ($ url, array $ params = array (), array $ headers = array ()) {$ headers ['GData-version'] = '2'; $ Request = new HTTP_Request2 ($ url); $ Request & gt; SetAdapter ('curl'); $ Request- & gt; Set config ('ssl_verify_peer', incorrect); $ Request & gt; SetHeader ($ header); $ Request & gt; SetMethod (HTTP_Request2 :: METHOD_POST); $ Request & gt; AddPostParameter ($ Parameter); Return $ request- & gt; Send (); }} $ Ga = New GA ('*********@gmail.com', '*********'); Var_dump ($ ga- & gt; call ('https://www.google.com/analytics/feeds/accounts/default'));  

Thanks in advance!

To answer my own question: should used trough < Strong> GET method My code is always POST .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -