1

I have a problem: I trying to send headers, but nothing happens.

This is a part of the headers from "Live HTTPHeaders"(i replaced the url):

http://some_site/news/

POST /news/ HTTP/1.1
Host: some_site
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://some_site/news/
Proxy-Authorization: Basic MTQ4YjU5YWMtM2VlOS00ZmIzLThlODItOTU0MjcxODhhZTRlOjAyNDdkNWRkNGY1MTE2NWUzODFlNDVhYTY1YzQ5OWYwMTRhYzA2ZTg=
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=---------------------------123064818248741452271123522
Content-Length: 893
-----------------------------123064818248741452271123522
Content-Disposition: form-data; name="BJpKD8Fx"

Hello!!!
-----------------------------123064818248741452271123522
Content-Disposition: form-data; name="file"; filename=""
Content-Type: application/octet-stream


-----------------------------123064818248741452271123522
Content-Disposition: form-data; name="parent"

155143
-----------------------------123064818248741452271123522
Content-Disposition: form-data; name="redirect"

0
-----------------------------123064818248741452271123522
Content-Disposition: form-data; name="eggs2"

UzFWa05qVnpjRmw4UWtwd1MwUTRSbmc9
-----------------------------123064818248741452271123522
Content-Disposition: form-data; name="submit"

Äîáàâèòü
-----------------------------123064818248741452271123522--

HTTP/1.1 302 Found

And this is my code:

<?php

 $parent = 155129;

 function doPost( $url = 'http://some_site/news', $postdata = '' ){

 $resource = curl_init();
 curl_setopt($resource, CURLOPT_URL, $url);
 curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt ($resource, CURLOPT_SSL_VERIFYPEER, 0);
 curl_setopt ($resource, CURLOPT_SSL_VERIFYHOST, 0);
 curl_setopt ($resource, CURLOPT_HTTPHEADER, array('Expect:'));
 curl_setopt ($resource, CURLOPT_HEADER, 1);
 curl_setopt ($resource, CURLOPT_COOKIEJAR, 'cookie.txt');
 curl_setopt($resource,CURLOPT_COOKIEFILE,'cookie.txt');
 curl_setopt($resource, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
 if( $postdata != '' ) {
     curl_setopt($resource, CURLOPT_POST, true);
     curl_setopt($resource, CURLOPT_POSTFIELDS, $postdata);
 }
 curl_setopt($resource, CURLOPT_FOLLOWLOCATION, true);
 $result = curl_exec($resource);
 curl_close($resource);
 return $result;

}

$c = doPost();
preg_match('#id="textarea_form_'.$parent.'" name="(.*?)"#ims', $c, $textName);
preg_match('#<form.*?\/form>#ims', $c, $arr );
preg_match('#name=eggs2.*?value="(.*?)">#ims', $arr[0], $egss2);

$postdata = array(
    $textName[1]=> 'Hello',
   'file'=>'@/;type=application/octet-stream',
   'parent' => $parent,
   'redirect'=> '0',
   'eggs2' => $egss2[1],
   'submit' => iconv('utf-8', 'cp1252', 'Добавить')
);

print_r(doPost('http://some_site/news',$postdata));
print_r( $postdata );

What I am doing wrong?

Thank you!

p.s. Hehehehehehehehehehehehehehehehehehehehehehe!!!! I solved! Thanks all for watching! Good-luck

1 Answer 1

0

You need to inject your headers like this :

curl_setopt($resource, CURLOPT_HTTPHEADER, array(
'X-Apple-Tz: 0',
'X-Apple-Store-Front: 143444,12'
));
Sign up to request clarification or add additional context in comments.

1 Comment

I did it, but result is the same... p.s.Thanks for the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.