2016-02-27 4 views
0

пытается проверить предоставленный код образца:ошибка загрузки асаны с Асана/PHP-асаны

$attachment = $client->attachments->createOnTask(
       $enquiry->id, 
       'hello word', 
       'upload.txt', 
       'text/plain' 
      ); 

Ошибка: 400 File is not an object

Клиент определенно работает (в состоянии создать задачу непосредственно перед). Задача ($enquiry->id) верна (проверяется путем перехода к URL-адресу и т. Д.).

Использование v0.4.0 библиотеки и PHP 5.6.18-1 у виртуальной машины Homestead.

Аналогичные вопросы о SO говорят о плохой кодировке, но все в порядке.

Ниже ответ:

class Httpful\Response#961 (13) { 
    public $body => 
    class stdClass#964 (1) { 
    public $errors => 
    array(1) { 
     [0] => 
     class stdClass#973 (2) { 
     ... 
     } 
    } 
    } 
    public $raw_body => 
    string(219) "{"errors":[{"message":"file: File is not an object","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}" 
    public $headers => 
    class Httpful\Response\Headers#963 (1) { 
    private $headers => 
    array(11) { 
     'server' => 
     string(5) "nginx" 
     'date' => 
     string(29) "Sat, 27 Feb 2016 02:36:49 GMT" 
     'content-type' => 
     string(31) "application/json; charset=UTF-8" 
     'transfer-encoding' => 
     string(7) "chunked" 
     'connection' => 
     string(10) "keep-alive" 
     'x-asana-content-string-length' => 
     string(3) "219" 
     'pragma' => 
     string(8) "no-cache" 
     'set-cookie' => 
     string(22) "TooBusyRedirectCount=0" 
     'cache-control' => 
     string(8) "no-store" 
     'x-asana-preferred-release-revision' => 
     string(56) "20160226_220201_ce3e88b3589d50e067532bbd0e824a44148e6738" 
     'x-robots-tag' => 
     string(4) "none" 
    } 
    } 
    public $raw_headers => 
    string(404) "HTTP/1.1 400 Bad Request 
Server: nginx 
Date: Sat, 27 Feb 2016 02:36:49 GMT 
Content-Type: application/json; charset=UTF-8 
Transfer-Encoding: chunked 
Connection: keep-alive 
X-Asana-Content-String-Length: 219 
Pragma: no-cache 
Set-Cookie: TooBusyRedirectCount=0 
Cache-Control: no-store 
X-Asana-Preferred-Release-Revision: 20160226_220201_ce3e88b3589d50e067532bbd0e824a44148e6738 
X-Robots-Tag: none" 
    public $request => 
    class Httpful\Request#962 (22) { 
    public $uri => 
    string(62) "https://app.asana.com/api/1.0/tasks/(task_id)/attachments" 
    public $method => 
    string(4) "POST" 
    public $headers => 
    array(2) { 
     'X-Asana-Client-Lib' => 
     string(118) "version=0.4.0&language=PHP&language_version=5.6.18-1%2Bdeb.sury.org%7Etrusty%2B1&os=Linux&os_version=3.19.0-25-generic" 
     'Authorization' => 
     string(41) "Bearer (valid bearer)" 
    } 
    public $raw_headers => 
    string(487) "POST /api/1.0/tasks/(task_id)/attachments HTTP/1.1 
Host: app.asana.com 
Expect: 
User-Agent: Httpful/0.2.20 (cURL/7.35.0 PHP/5.6.18-1+deb.sury.org~trusty+1 (Linux)) 
Content-Type: multipart/form-data 
Accept: */*; q=0.5, text/plain; q=0.8, text/html;level=3;q=0.9, application/json 
X-Asana-Client-Lib: version=0.4.0&language=PHP&language_version=5.6.18-1%2Bdeb.sury.org%7Etrusty%2B1&os=Linux&os_version=3.19.0-25-generic 
Authorization: Bearer 0/88eebe64d4af7bd966936bbe346be679 
" 
    public $strict_ssl => 
    bool(false) 
    public $content_type => 
    string(19) "multipart/form-data" 
    public $expected_type => 
    string(16) "application/json" 
    public $additional_curl_opts => 
    array(0) { 
    } 
    public $auto_parse => 
    bool(true) 
    public $serialize_payload_method => 
    int(0) 
    public $username => 
    NULL 
    public $password => 
    NULL 
    public $serialized_payload => 
    array(1) { 
     'file' => 
     string(48) "@/tmp/YCRYJd;filename=upload.txt;type=text/plain" 
    } 
    public $payload => 
    array(1) { 
     'file' => 
     string(48) "@/tmp/YCRYJd;filename=upload.txt;type=text/plain" 
    } 
    public $parse_callback => 
    NULL 
    public $error_callback => 
    NULL 
    public $send_callback => 
    NULL 
    public $follow_redirects => 
    bool(false) 
    public $max_redirects => 
    int(25) 
    public $payload_serializers => 
    array(0) { 
    } 
    public $_ch => 
    resource(652) of type (Unknown) 
    public $_debug => 
    NULL 
    } 
    public $code => 
    int(400) 
    public $content_type => 
    string(16) "application/json" 
    public $parent_type => 
    string(16) "application/json" 
    public $charset => 
    string(5) "UTF-8" 
    public $meta_data => 
    array(26) { 
    'url' => 
    string(62) "https://app.asana.com/api/1.0/tasks/(task_id)/attachments" 
    'content_type' => 
    string(31) "application/json; charset=UTF-8" 
    'http_code' => 
    int(400) 
    'header_size' => 
    int(408) 
    'request_size' => 
    int(552) 
    'filetime' => 
    int(-1) 
    'ssl_verify_result' => 
    int(0) 
    'redirect_count' => 
    int(0) 
    'total_time' => 
    double(3.435421) 
    'namelookup_time' => 
    double(2.1E-5) 
    'connect_time' => 
    double(0.29363) 
    'pretransfer_time' => 
    double(2.023479) 
    'size_upload' => 
    double(187) 
    'size_download' => 
    double(219) 
    'speed_download' => 
    double(63) 
    'speed_upload' => 
    double(54) 
    'download_content_length' => 
    double(-1) 
    'upload_content_length' => 
    double(187) 
    'starttransfer_time' => 
    double(2.023485) 
    'redirect_time' => 
    double(0) 
    'redirect_url' => 
    string(0) "" 
    'primary_ip' => 
    string(12) "52.70.61.144" 
    'certinfo' => 
    array(0) { 
    } 
    'primary_port' => 
    int(443) 
    'local_ip' => 
    string(9) "10.0.2.15" 
    'local_port' => 
    int(49537) 
    } 
    public $is_mime_vendor_specific => 
    bool(false) 
    public $is_mime_personal => 
    bool(false) 
    private $parsers => 
    NULL 
} 


[Asana\Errors\InvalidRequestError] 
Invalid Request 

ответ

1

Посмотрел на него и Асана/PHP-асана uploadFile код не совместим с PHP 5.6+. Запрос

Прицепные: here

+0

Благодаря Arnaud - мы будем смотреть! –