duanbi3786 2019-03-07 04:31
浏览 177
已采纳

这是ASYNC REQUEST。 你能帮助我改变你在php中的Curl吗? [关闭]

Here the details

https://api.offertest.net/offertest[?async=true]

curl -i -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJvZUF1VU5yZVJXNmN5cHdKcGNnbmxRIiwiaWF0IjoxNTUxOTMxNzU3LCJqdGkiOiJUanNUaF9sUkY4MUR0VER5aWQ3bG9BIn0.DLgPiNNDHJMZTufUHS5nYTD_j3ImvxIfhMNrqlcl4LA" -X POST -d '{"userid":"oeAuUNreRW6cypwJpcgnlQ", "country":"us", "url":"http://www.google.com/","platform": "android", "callback":"http://{YOURAPIURL}/offertest/{YOURCAMPAIGNID}/result"}' -H "Content-type: application/json" https://api.offertest.net/offertest?async=true
  • 写回答

1条回答 默认 最新

  • douyan1321 2019-03-07 04:36
    关注

    You can try below code :

    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, 'https://api.offertest.net/offertest?async=true');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"userid\":\"oeAuUNreRW6cypwJpcgnlQ\", \"country\":\"us\", \"url\":\"http://www.google.com/\",\"platform\": \"android\", \"callback\":\"http://{YOURAPIURL}/offertest/{YOURCAMPAIGNID}/result\"}");
    curl_setopt($ch, CURLOPT_POST, 1);
    
    $headers = array();
    $headers[] = 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJvZUF1VU5yZVJXNmN5cHdKcGNnbmxRIiwiaWF0IjoxNTUxOTMxNzU3LCJqdGkiOiJUanNUaF9sUkY4MUR0VER5aWQ3bG9BIn0.DLgPiNNDHJMZTufUHS5nYTD_j3ImvxIfhMNrqlcl4LA';
    $headers[] = 'Content-Type: application/json';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }
    curl_close ($ch);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示