使用php通过api在formstack中创建webhook url

使用php通过api在formstack中创建webhook url,php,formstack,Php,Formstack,我想通过id为pitifuller表单创建一个webhook url这是我的代码我不知道我的错误是什么 define('CLIENT_ID', 'client_id'); define('CLIENT_SECRET', 'client_secret'); define('REDIRECT_URL', 'redirect url'); // for testing, use the URL to this PHP file. define('AUTHORIZE_URL', 'htt

我想通过id为pitifuller表单创建一个webhook url这是我的代码我不知道我的错误是什么

 define('CLIENT_ID', 'client_id');
 define('CLIENT_SECRET', 'client_secret');
 define('REDIRECT_URL', 'redirect url'); // for testing, use    the URL to this PHP file.

 define('AUTHORIZE_URL', 'https://www.formstack.com/api/v2/oauth2/authorize');
 define('TOKEN_URL', 'https://www.formstack.com/api/v2/oauth2/token');
 $ch = curl_init(TOKEN_URL);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
'grant_type' => 'authorization_code',
'client_id' => CLIENT_ID,
'redirect_uri' => REDIRECT_URL,
'client_secret' => CLIENT_SECRET,
'id' => 'id', // here is my id
'url' => 'web_hook_url' // here is my webhook url which i want to create
 )));
// oauth2 contains the the access_token.
 $oauth2 = json_decode(curl_exec($ch));

您在CURL调用中犯了错误,目前您正在GET表单中传递post数据,您需要这样传递(post-form/:id/webhook),您可以这样做:

$ch = curl_init('https://www.formstack.com/api/v2/form/your-form-id/webhook');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $oauth2->access_token
));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
'id' => $_POST['id'],
 'url' => 'http://www.getbravo.com/formstack/index.php',
'append_data' => '1'
)));
你会得到这样的回应

 $forms = json_decode(curl_exec($ch)); 
 print '<pre>';
 print_r($forms);
 print '</pre>'; 
$forms=json_decode(curl_exec($ch));
打印“”;
打印(表格);
打印“”;