Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
371 views
in Plugins by

I am trying to develop a plugin for external website to integreat entire ask form (not only title field but everything) I tried using cURL but somehow it is not submiting question. Any one can help me to make it work

Fields Required:

  • Title
  • Category
  • Content
  • Tags
  • Notify checkbox
  • Submit

Here is my cURL code but I am not able to figure out what is wrong. Is that url or something in code or field name

$url = 'http://localhost/qa/ask';

 

$fields = array(
            'title'=>$_POST['title'],
'content'=>$_POST['content'],
'tags'=>$_POST['tags'],
'q_notify'=>$_POST['q_notify'],
 
        );
 
$fields_string = '';
foreach($fields as $key=>$value) { 
$fields_string .= $key.'='.urlencode($value).'&';
}
$fields_string = substr($fields_string, 0, -1);
 
$ch = curl_init();
 
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 
$result = curl_exec($ch);
 
curl_close($ch);
Q2A version: 1.5.3

Please log in or register to answer this question.

...