需要知道鳕鱼的语言

时间:2019-03-13 01:16:35

标签: php curl

我需要一些帮助来了解代码语言

您能告诉您使用哪种语言编写此代码吗?我想使用izooto api,他们给了我示例代码

以下为示例代码

curl -X POST \        
 - H "Authentication-Token: abc123efgh456ijklmn9786" \
 - H "Content-Type: application/json" \
 -d '{
 "title" : "Limited Period Offer",
 "message" : "Go Shopping, Save Big",
 "icon_url" : "https://yourdomain.com/icon.png",
 "banner_url" : "https://yourdomain.com/large-image.png",
 "landing_url" : "https://yourdomain.com/offers",
 "actions" : [
 {
 "text" : "Buy Now",
 "url" : "https://yourdomain.com/buy-now"
 },
 {
 "text" : "Compare",
 "url" : "https://yourdomain.com/compare"
 }],
 "utm_source" : "izooto",
 "utm_medium" : "push_notification",
 "utm_campaign" : "promotion",
 "ttl" : "86400",
 "target" : {
 "type" : "all"
 }
 }' "https://apis.izooto.com/v1/notifications"

但是我不知道如何以及在哪里使用。它是用PHP还是哪种语言?

我想在PHP中使用此代码。谁能帮我

1 个答案:

答案 0 :(得分:1)

这不是编程语言代码块。这是一个使用HTTP POSTCURL请求。因此,如果您想向PHP(这是一种服务器端编程语言)发出此请求,可以尝试使用一个简单的在线工具,使您的CURL请求轻松地转化为PHP。我已将HTTP POST转换为在线使用tool,然后进行轻微修改

另请参阅PHP CURL的手册

 // Generated by POSTMAN client
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://apis.izooto.com/v1/notifications",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n  \"title\": \"Limited Period Offer\",\n  \"message\": \"Go Shopping, Save Big\",\n  \"icon_url\": \"https://yourdomain.com/icon.png\",\n  \"banner_url\": \"https://yourdomain.com/large-image.png\",\n  \"landing_url\": \"https://yourdomain.com/offers\",\n  \"actions\": [\n    {\n      \"text\": \"Buy Now\",\n      \"url\": \"https://yourdomain.com/buy-now\"\n    },\n    {\n      \"text\": \"Compare\",\n      \"url\": \"https://yourdomain.com/compare\"\n    }\n  ],\n  \"utm_source\": \"izooto\",\n  \"utm_medium\": \"push_notification\",\n  \"utm_campaign\": \"promotion\",\n  \"ttl\": \"86400\",\n  \"target\": {\n    \"type\": \"all\"\n  }\n}",
  CURLOPT_HTTPHEADER => array(
    "Authentication-Token: abc123efgh456ijklmn9786",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}