Thanks for the library but I could not find any documentation about it!
It will be grate if you will give a code sample for the post request:
URL : http://www.example.com
postContent : param1=value1¶m2=value2¶m2=value2
pr0gr4mm3r posted this at 14:45 — 4th December 2008.
You can Google search "snoopy examples" and find some more helpful ways to request page, scan a page for links, troubleshoot errors, etc. Hope this helps.
$ch = curl_init("http://www.example.com"); curl_setopt($ch, CURLOPT_POST, 1); // Sending Post Items curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postVars,0,-1)); (chop of ending & curl_setopt($ch, CURLOPT_HEADER, 0); // Don't include headers in result curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return page instead of display $remotePage = curl_exec($ch); curl_close($ch);
?>
PS. I have no idea why the $aryPost = array( line is wrapping like it does... shows fine in the editor... (grumble about this RTE)
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.
pr0gr4mm3r posted this at 14:24 — 3rd December 2008.
He has: 1,502 posts
Joined: Sep 2006
Check out the Snoopy library. It is a library that helps you fetch pages, post data, and more. Post back if you want some code examples.
MH-Dolly posted this at 08:44 — 4th December 2008.
He has: 20 posts
Joined: Dec 2008
Hello!
Thanks for the library but I could not find any documentation about it!
It will be grate if you will give a code sample for the post request:
URL : http://www.example.com
postContent : param1=value1¶m2=value2¶m2=value2
pr0gr4mm3r posted this at 14:45 — 4th December 2008.
He has: 1,502 posts
Joined: Sep 2006
Here you go:
<?php
require('snoopy.php');
$snoopy = new Snoopy();
$url = 'http://www.example.com';
$data['param1'] = 'value1';
$data['param2'] = 'value2';
$data['param3'] = 'value3';
$snoopy->submit($url, $data);
?>
You can Google search "snoopy examples" and find some more helpful ways to request page, scan a page for links, troubleshoot errors, etc. Hope this helps.
Greg K posted this at 18:26 — 4th December 2008.
He has: 2,145 posts
Joined: Nov 2003
This is most likely a class to wrap the curl function, probably with some more advanced features, but if you just need a down and dirty script
<?php
$aryPost = array('param1'=>"value1",
'param2'=>"value2",
'param3'=>"value3");
$postVals = '';
foreach($aryPost as $key=>$val)
$postVals .= urlencode($key)."=".urlencode($val)."&";
$ch = curl_init("http://www.example.com");
curl_setopt($ch, CURLOPT_POST, 1); // Sending Post Items
curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postVars,0,-1)); (chop of ending &
curl_setopt($ch, CURLOPT_HEADER, 0); // Don't include headers in result
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return page instead of display
$remotePage = curl_exec($ch);
curl_close($ch);
?>
PS. I have no idea why the $aryPost = array( line is wrapping like it does... shows fine in the editor... (grumble about this RTE)
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.