I've used curl before to post "field" data to a server, but in this
case, I actaully need to post JSON data. However, when I run this PHP
script, I get nothing back. If I do this curl manually in Terminal,
it works.
I'm pretty sure the bug has something to do with CURLOPT_POSTFIELDS -
- - I just don't know what the alternative is. Basically I need to
post this data:
{siteUrl:\"http://testurl.com\",siteRss:\"http://feeds.news.mysite.com/synfeeds/collect/6/rss.xml
\",userName:\"testuser\",email:\"testemail\",siteName:\"testsitename
\",loginId:\"testloginid\}
to the url:
http://dpdev-ld03.myservercom:8181/linkmethod/signup?f=json&c=signupcallback
Any obvious mistakes below?
<?php
$ch = curl_init();
$timeout = 10; // set to zero for no timeout
$urltouse = "http://dpdev-ld03.myservercom:8181/linkmethod/signup?f=json&c=signupcallback
";
$fields_string = '{siteUrl:\"http://testurl.com\",siteRss:\"http://feeds.news.mysite.com/synfeeds/collect/6/rss.xml
\",userName:\"testuser\",email:\"testemail\",siteName:\"testsitename
\",loginId:\"testloginid\}';
curl_setopt($ch,CURLOPT_URL,$urltouse);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); <-- shouldn't be
postfields, but some other curl option I'm guessing
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php