Thread: Posting with cURL
Caligula

Not to long ago... Bompa commented something along the lines of " if you can post to google you can post anywhere" ..... So....  I have made that my first goal in

learn

 ing  the art of link spamming....  hehe.....  nevertheless... its not going so good.. I guess the real question is, is google harder to post to than some bullshit guestbook..or am I going in the wrong direction with my code....



$key = urlencode(keyword);

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com");
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "safe=off&q=$key&start=0&num=10&sa=N");
$result=curl_exec ($ch);
curl_close ($ch);

echo $result;



I have tried the POSTFIELDS statement 100 different ways and all I get is a "Not Implemented" message... which according to google means they cannot recognize the request. What am I doing wrong?


cdc

Hmm...it looks ok at face value.

Have you tried removing the POST_FIELDS line and just loading google.com? This will let you know if curl is working pro

perl

 y on your server.

nop_90

stupid question,
but isn't G a get ? not a post ?

Bompa

quote author=nop_90 link=topic=213.msg1331#msg1331 date=1179129242

stupid question,
but isn't G a get ? not a post ?


Come to think of it, maybe it is.  Not sure what I was thinking when I said post to Google.

Here is from Google's search page:

<form action="/search" name=f>

There is no 'method', so isn't the default POST?

Maybe their backend will accept either?

Shit, I dunno.  That'lll

teach

  yah to listen to me Cal.

Bompa

Bompa

Cal,

You would need to post to the url in their form, (Google's or whoever).

Google's is /search

so try www.google.com/search in your code


cdc

Good catch, Bomps.

Caligula, if you're going to start submitting forms I highly recommend downloading the HTTP Headers toolbar for firefox. It will tell you the URL you need to post to and all the fields it expects.

Caligula

Something tells me you all just jumped into guest books, forums and all... without ever trying the google thing....lol

ok... well.... apparently.. cURL sends a GET request by default... enabling POSTFIELDS tells it to post... but if left out.... you get..GET...  get it?

This works..


$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/search?safe=off&q=keyword&start=0&num=10&sa=N");
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;



- That LiveHTTPHeaders thing for fire fox kicks ass by the way...  Applause

Applause

m0nkeymafia

I always use FireBug too
It can tell you request and response headers for current and previous connections.

It also gives you load times for each connection so you can tell if a particular

ajax

  call takes too long.
Bleedin rocks!

Bompa

quote author=Caligula link=topic=213.msg1383#msg1383 date=1179192244

Something tells me you all just jumped into guest books, forums and all... without ever trying the google thing....lol

ok... well.... apparently.. cURL sends a GET request by default... enabling POSTFIELDS tells it to post... but if left out.... you get..GET...  get it?

This works..


$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/search?safe=off&q=keyword&start=0&num=10&sa=N");
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;



- That LiveHTTPHeaders thing for fire fox kicks ass by the way...  Applause

Applause


Woohooo!  Glad you got it working.  Now you can post anywhere Applause  sorta.  Applause

Where you have echo $result in your code, does that actually display Google's
source html?  You will need that ability.  Some sites have a session ID or other
parameter on their page that must be included in the POST fields, they do this
to prevent those spammy ppl from just posting without visiting the page first.  Applause



later,
Bompa

Caligula

quote author=Bompa link=topic=213.msg1397#msg1397 date=1179227233

quote author=Caligula link=topic=213.msg1383#msg1383 date=1179192244

Something tells me you all just jumped into guest books, forums and all... without ever trying the google thing....lol

ok... well.... apparently.. cURL sends a GET request by default... enabling POSTFIELDS tells it to post... but if left out.... you get..GET...  get it?

This works..


$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/search?safe=off&q=keyword&start=0&num=10&sa=N");
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;



- That LiveHTTPHeaders thing for fire fox kicks ass by the way...  Applause

Applause


Woohooo!  Glad you got it working.  Now you can post anywhere Applause  sorta.  Applause

Where you have echo $result in your code, does that actually display Google's
source html?  You will need that ability.  Some sites have a session ID or other
parameter on their page that must be included in the POST fields, they do this
to prevent those spammy ppl from just posting without visiting the page first.  Applause


later,
Bompa



Thanks Bompa  Applause

The echo in the code returns the result page for whatever search term you put in - just as if you were doing a reg G search....only its through the script so its my domain not G's and none of the images show..hehe..... is that what you mean?

I know its pretty much a useless script at this point... but at least I am a little closer to understanding how to post with cURL.... especially since info about this is kinda vague... Now I have to find and install some shit GB script so I can figure out exactly how to post to it.... since I really don't want to practice on someone elses site... lol


nop_90

quote author=Caligula link=topic=213.msg1418#msg1418 date=1179265581

Now I have to find and install some shit GB script so I can figure out exactly how to post to it.... since I really don't want to practice on someone elses site... lol


People like you make me sick  Applause

perkiset

No that's just your flu Nop. You'll get over it. Take two cookies, idle your processor and call us in 86,400,000ms.

/p

Bompa

quote author=nop_90 link=topic=213.msg1443#msg1443 date=1179305004

quote author=Caligula link=topic=213.msg1418#msg1418 date=1179265581

Now I have to find and install some shit GB script so I can figure out exactly how to post to it.... since I really don't want to practice on someone elses site... lol


People like you make me sick  Applause



Applause

Caligula

quote author=nop_90 link=topic=213.msg1443#msg1443 date=1179305004

quote author=Caligula link=topic=213.msg1418#msg1418 date=1179265581

Now I have to find and install some shit GB script so I can figure out exactly how to post to it.... since I really don't want to practice on someone elses site... lol


People like you make me sick  Applause



I....I....I don't know what I've done to offend you... but I can say that whatever it was, I am truly deeply sorry... please forgive Me....







perkiset

Applause  Applause  Applause

m0nkeymafia

Man you guys  Applause

After reading this, and some other stuff about curl
I went ahead on gone n become a curly master! [ish lol]

Wooo curl rocks, I can post, scrape secure sites, and tie my shoelaces!!
Now I just gotta figure out where guestbooks are and how to find them LOLOL

perkiset

cURL does rock... although I use it rarely (have my own classes) it is a very strong lib and

PHP

 's connection to it is pretty good.

Now I wonder if you might post a little something on the whole "Tie your shoelaces" thing... I personally have that nailed but I'd sign my two teenage sons up for the forum in a skinny minute just to take in that little tidbit  Applause

m0nkeymafia

i wear velcro Applause
lol
no shoelaces
again
im drunk
forgive me
mauabubaubaahauua Applause ooh poliece


Perkiset's Place Home   Politics @ Perkiset's