googleapis / google-api-php-client

A PHP client library for accessing Google APIs
http://googleapis.github.io/google-api-php-client/
Apache License 2.0
9.32k stars 3.52k forks source link

Problems with xlsx body #223

Closed webalexstudio closed 10 years ago

webalexstudio commented 10 years ago

Hi, I try to get spreadsheet xlsx body. Getting file is OK, but while getting getResponseBody() invalid encoding is there. This is my part of code: if ($downloadUrl) { $request = new Google_Http_Request($downloadUrl); $clientAuth = $this->_getClient()->getAuth(); $httpRequest = $clientAuth->authenticatedRequest($request);

        if ($httpRequest->getResponseHttpCode() == 302) {
            $responseHeaders = $httpRequest->getResponseHeaders();
            $location = $responseHeaders['location'];
            $httpRequest->setUrl($location);
            $httpRequest = $clientAuth->authenticatedRequest($request);
        }

        if ($httpRequest->getResponseHttpCode() == 200) {
            $headers = $httpRequest->getResponseHeaders();
            $body = $httpRequest->getResponseBody();
                            /*Here I have problem*/

The body is: PK���8�D���������������xl/drawings/drawing1.xml��AN�0�p�h�� ����D��0ؓ��c[3.mo�Eɾ���k���p�r�~H4�4�󾇎��.�e�Ϗ��tZ19�9�7R8�W'�E'��}ҡ�|�e0F�'F��B��s�ڢ,�^��Ѽ����"�N=Q���{�Ac i�hM��i��̔��X�/ԇ��f7�����?$0����l��6|���[���%.�"���PK�`(�������PK���8�D���������������xl/worksheets/sheet1.xml���n� �����؏�8�4�lGI���UUӮ�c4,�?y�^� �t��c���8\Cq?���X�U��I�WL�B�K���ys��uTմӊ���[|})&m���!�([�ֹ>'IJ�Kj�sm$u05{b{�iL�#Y��I�� !7k�i�O��+�@ 糖���=��|���mu�����3�!��Y ��$���~�R��N���+b�F�G�&�����Gٝ��v�.�E3���Yz ���gQIr&���_�"  >����7�~�R�8Ť_ȅ�94��Al�N��\�[G��7t��7���k��KvW��SOQ|�|��x�;�H  ��H�9��R�n<�[�!�u�_�ï¿

I tried to encode it but have no result .

In same time when I get response body of doc spreadsheet I get this one: {\rtf1\ansi\ansicpg1252\uc0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deff0\adeff0{\fonttbl{\f0\froman\fcharset0\fprq2{\panose 02020603050405020304}Times New Roman;}{\f1\froman\fcharset2\fprq2{\panose 05050102010706020507}Symbol;}{\f2\fswiss\fcharset0\fprq2{*\panose 020b0604020202020204}Arial;}{\f3\fnil\fcharset0 Georgia;}}{ \colortbl;\red0\green0\blue0;\r

ianbarber commented 10 years ago

This seems like an issue with the Drive API rather than the client library directly - try asking the Drive team who may have a better idea of what the issue might be! https://developers.google.com/drive/support

webalexstudio commented 10 years ago

Thx for your answer