首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用curl php与monday.com连接以在monday.com中创建销售线索或交易?

如何使用curl php与monday.com连接以在monday.com中创建销售线索或交易?
EN

Stack Overflow用户
提问于 2021-11-10 09:52:08
回答 1查看 36关注 0票数 0

我查看了API文档,但没有与curl php相关的示例。

我能得到一些关于如何使用curl php在monday.com中创建销售线索或交易的monday.com的指南吗?

我有示例代码(此代码片段中的Token是错误的),但我不知道如何传递数据来创建lead

代码语言:javascript
复制
<?php
    $token = 'eyJhbGciOiJIUzI1NiJ9.0Y-0OesftWBt2SamhvuPV5MR-0Oq7iApMt2exFkDNdM';
    $apiUrl = 'https://api.monday.com/v2';
    $headers = ['Content-Type: application/json', 'Authorization: ' . $token];

    $query = '{ boards (limit:1) {id name} }';
    $data = @file_get_contents($apiUrl, false, stream_context_create([
      'http' => [
        'method' => 'POST',
        'header' => $headers,
        'content' => json_encode(['query' => $query]),
      ]
    ]));
    $responseContent = json_decode($data, true);

    echo json_encode($responseContent);
?>
EN

回答 1

Stack Overflow用户

发布于 2021-11-11 14:40:07

我对这个monday.com页面并不熟悉,但这就是在PHP中发出cURL请求的方法:

代码语言:javascript
复制
<?php
$token = 'eyJhbGciOiJIUzI1NiJ9.0Y-0OesftWBt2SamhvuPV5MR-0Oq7iApMt2exFkDNdM';
$apiUrl = 'https://api.monday.com/v2';
$headers = ['Content-Type: application/json', 'Authorization: ' . $token];

//  Payload
$query = '{ boards (limit:1) {id name} }';
$payload = ['query' => $query];

//  Init cURL
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $apiUrl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

//  Exec cURL
$resp = curl_exec($curl);

//  Close cURL
curl_close($curl);

//  Get response
$response = @json_decode($resp, true);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69911074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档