Welcome Guest, Not a member yet? Register   Sign In
Curl Request - left inact
#1
Question 

Hi all, i cannot reproduce problem 2 days. Making request to coinbase api and getting as answer string(74) "��V�,�W�R2202�50�5212�2��26�311�R�QJ-�O�P�245��0434K�����9"

There is something written ISO.. but i think it is useless, because response is not getting full answer as i uderstand..


Unless otherwise specified, all timestamps from API are returned in ISO 8601 with microseconds. Make sure you can parse the following ISO 8601 format. Most modern languages and libraries will handle this without issues.

My code:

Quote:$client = Services::curlrequest();
$response = $client->request('GET', 'https://api-public.sandbox.pro.coinbase.com/time',
    ['debug' => '/var/www/html/logs/curl.txt']
);
$this->data['info'] = $response->getBody();



Answer should be something like this:
Code:
{
    "iso": "2015-01-07T23:47:25.201Z",
    "epoch": 1420674445.201
}


Code:
*  Trying 104.18.15.237:443...
* TCP_NODELAY set
* Connected to api-public.sandbox.pro.coinbase.com (104.18.15.237) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: none
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=CA; L=San Francisco; O=Cloudflare, Inc.; CN=pro.coinbase.com
*  start date: Sep 12 00:00:00 2019 GMT
*  expire date: Sep 11 12:00:00 2020 GMT
*  subjectAltName: host "api-public.sandbox.pro.coinbase.com" matched cert's "*.sandbox.pro.coinbase.com"
*  issuer: C=US; ST=CA; L=San Francisco; O=CloudFlare, Inc.; CN=CloudFlare Inc ECC CA-2
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x564cdf0b89e0)
> GET /time HTTP/2
Host: api-public.sandbox.pro.coinbase.com
Cdn-Loop: cloudflare
Cf-Connecting-Ip: 212.142.106.33
Cookie: __cfduid=deafeb45a17ff5cc8a45e9c19a30208821579754764; debug-bar-tab=ci-vars; debug-bar-state=minimized
Accept-Language: en-US,en;q=0.9
Referer: https://somesite.com/crypto_migrate
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-User: ?1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Cf-Visitor: {"scheme":"https"}
X-Forwarded-Proto: https
Cf-Ray: 559cfa64ca36b4cc-RIX
X-Forwarded-For: MY IP*
Cf-Ipcountry: LV
Accept-Encoding: gzip
Connection: Keep-Alive

* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200
< date: Thu, 23 Jan 2020 21:49:32 GMT
< content-type: application/json; charset=utf-8
< access-control-allow-headers: Content-Type, Accept, cb-session, cb-fp, cb-form-factor
< access-control-allow-methods: GET,POST,DELETE,PUT
< access-control-allow-origin: *
< access-control-expose-headers: cb-before, cb-after, cb-gdpr
< access-control-max-age: 7200
< cache-control: no-store
< etag: W/"39-Vl/+OyC8kIsj7lUWn7LPmpI92uY"
< strict-transport-security: max-age=15552000; includeSubDomains
< x-content-type-options: nosniff
< x-dns-prefetch-control: off
< x-download-options: noopen
< x-frame-options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< cf-cache-status: MISS
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< vary: Accept-Encoding
< server: cloudflare
< cf-ray: 559cfa655df240da-HAM
< content-encoding: gzip
<
* Connection #0 to host api-public.sandbox.pro.coinbase.com left intact

When i make with codeigniter request curl, cmd curl to akamai http://time.akamai.com than i getting working response..
What im doing wrong?

Thank you!
Reply
#2
Thumbs Up 

I'm done, to reproduce error, ill set ['http_errors' => false] and than i see correct error was string(44) "{"message":"User-Agent header is required."}" and was set 'User-Agent' => 'MI6' ))

Thank's anyway!

PHP Code:
$client Services::curlrequest([
            'base_uri' => 'https://api.pro.coinbase.com/',
            'debug' => '/var/www/html/logs/curl.txt'
        ]);
        $response $client->get('time',[
            'headers' => [
                'User-Agent' => 'MI-6',
                'Accept'    => 'application/json',
            ],
            'http_errors' => false
        
]); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB