Есть запрос такого формата который отлично срабатывает:
curl "https://forklog.com/wp-content/themes/newForklog/ajaxposts.php"
-H "Referer: https://forklog.com/news/"
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
-H "X-Requested-With: XMLHttpRequest"
-H "Connection: keep-alive"
--data "action=PostsByCat&offset=12&postperpage=12&category=news/&tag=news/"
Но вот если сделать аналогичное через curl php, то выдает пустоту, с чем это связано?
Log:
* upload completely sent off: 71 out of 71 bytes
* Trying 178.62.211.70...
* TCP_NODELAY set
* Connected to forklog.com (178.62.211.70) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: OU=Domain Control Validated; OU=PositiveSSL; CN=forklog.com
* start date: Jan 28 00:00:00 2017 GMT
* expire date: Jan 28 23:59:59 2019 GMT
* subjectAltName: host "forklog.com" matched cert's "forklog.com"
* issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
* SSL certificate verify ok.
> POST /wp-content/themes/newForklog/ajaxposts.php HTTP/1.1
Host: forklog.com
Accept: */*
https://forklog.com/news/
Content-Length: 71
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 71 out of 71 bytes
< HTTP/1.1 200 OK
< Server: nginx/1.10.3
< Date: Mon, 13 Aug 2018 14:33:29 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
<
* Curl_http_done: called premature == 0
* Connection #0 to host forklog.com left intact
Код:
$response = Curl::to('https://forklog.com/wp-content/themes/newForklog/ajaxposts.php')
->withData(array(
'action' => 'PostsByCat',
'offset'=> 12,
'postperpage' => 12,
'category' => 'news/',
'tag' => 'news/'))
->withHeaders(array(
'Referer' => 'https://forklog.com/news/',
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With' => 'XMLHttpRequest',
'Connection' => 'keep-alive'
))->post();
Либа:
https://github.com/ixudra/curl