【问题标题】:Create webhook-url in formstack via api using php使用 php 通过 api 在 formstack 中创建 webhook-url
【发布时间】:2014-05-30 18:12:21
【问题描述】:

我想通过 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));

【问题讨论】:

    标签: php formstack


    【解决方案1】:

    您在 CURL 调用中犯了错误,目前您正在以 GET 形式传递 post 数据,您需要通过 Like this(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>'; 
    

    【讨论】:

      猜你喜欢
      • 2013-05-01
      • 2016-01-23
      • 2013-04-30
      • 2017-11-13
      • 2018-05-08
      • 2018-05-24
      • 1970-01-01
      • 1970-01-01
      • 2017-06-08
      相关资源
      最近更新 更多