如何将文件发布到Globiflow Webhooks?

时间:2019-02-06 20:27:43

标签: php curl post php-curl podio

Globiflow声明以下内容:“已发布的文件将添加到使用任何已发布的字段标记的任何“创建项目”,“更新收集的”或“收集的注释”操作中。”

Reference: Globiflow Webhook help page

以下内容将参数发布到Globiflow,但未附加文件:

$post_url = 'https://secure.globiflow.com/catch/abcdefghijklmnop';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
$i = 0;
$files = [
    '/home/website/public_html/path/to/file1.jpg',
    '/home/website/public_html/path/to/file2.jpg',
];
foreach($files as $file) {  
    curl_setopt(
        $ch,
        CURLOPT_POSTFIELDS,
        array(
            'file['.$i++.']' => '@' . realpath($file)
        )
    );
}
$params = array(
    'arg1' => 'abc',
    'arg2' => 'def'
);
$query = http_build_query($body);
$url = $post_url.'?'.$query;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);

// output the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

// close the session
curl_close($ch);
print_r( $response );

0 个答案:

没有答案