POSTING to a wordpress blog using cURL.
Posted: Sun Feb 24, 2008 4:08 am
~pickle | Please use
I just started learning PHP so.. 
~pickle | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hey all, I just joined this great forum and I'm having some problems with my code so it'd be great if someone could give me a hand.
I'm trying to post a comment to a wordpress blog using cURL, and it's not working for some reason. Here's the code :Code: Select all
<?php
$url = "http://blog.shankarganesh.com/2007/12/20/warning-a-worm-is-spreading-through-orkut/";
$post_fields = "author=username&email=blahblah@gmail.com&url=nothing.com&comment=Thanks&submit=Submit+Comment&comment_post_ID=328&subscribe=subscribe";
$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$c_path = "C:/php/cook";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEFILE, $c_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $c_path);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
?>
~pickle | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]