The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 02:42:35 PM

Login with username, password and session length


Pages: [1] 2
  Print  
Author Topic: Posting with cURL  (Read 8705 times)
Caligula
Rookie
**
Offline Offline

Posts: 39



View Profile
« on: May 13, 2007, 07:10:22 PM »

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 learning 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....

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?


Logged
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #1 on: May 13, 2007, 11:40:02 PM »

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 properly on your server.
Logged

Will code for food.
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #2 on: May 14, 2007, 12:54:02 AM »

stupid question,
but isn't G a get ? not a post ?
Logged
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #3 on: May 14, 2007, 03:24:36 AM »

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
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #4 on: May 14, 2007, 03:28:16 AM »

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


Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #5 on: May 14, 2007, 04:06:59 AM »

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.
Logged

Will code for food.
Caligula
Rookie
**
Offline Offline

Posts: 39



View Profile
« Reply #6 on: May 14, 2007, 06:24:04 PM »

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..

Code:
$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...  Wink

 Mobster
Logged
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #7 on: May 15, 2007, 01:15:33 AM »

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!
Logged

I am Tyler Durden
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #8 on: May 15, 2007, 04:07:13 AM »

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..

Code:
$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...  Wink

 Mobster

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

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.  Cheesy



later,
Bompa
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Caligula
Rookie
**
Offline Offline

Posts: 39



View Profile
« Reply #9 on: May 15, 2007, 02:46:21 PM »

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..

Code:
$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...  Wink

 Mobster

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

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.  Cheesy


later,
Bompa


Thanks Bompa  Mobster

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


Logged
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #10 on: May 16, 2007, 01:43:24 AM »

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  Vomit
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #11 on: May 16, 2007, 10:14:29 AM »

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
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #12 on: May 16, 2007, 07:08:39 PM »

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  Vomit


 Huh?

Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Caligula
Rookie
**
Offline Offline

Posts: 39



View Profile
« Reply #13 on: May 16, 2007, 07:10:20 PM »

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  Vomit


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....







Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #14 on: May 16, 2007, 09:42:38 PM »

ROFLMAO  ROFLMAO  ROFLMAO
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1] 2
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!