<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to post to Http Event Collector with PHP? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-post-to-Http-Event-Collector-with-PHP/m-p/474977#M81565</link>
    <description>&lt;P&gt;All, &lt;/P&gt;

&lt;P&gt;Anyone ever post to HEC using PHP? Got a working example? Or see where I am going wrong?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?php
        $ch = curl_init("https://10.x.x.x:8088/services/collector/event");
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERPWD, "x:MYTOKEN");
        curl_setopt($ch, CURLOPT_POSTFIELDS, "number=10");
        $output = curl_exec($ch);
        curl_close($ch);
        echo $output;
?&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 21 Feb 2020 00:47:00 GMT</pubDate>
    <dc:creator>daniel333</dc:creator>
    <dc:date>2020-02-21T00:47:00Z</dc:date>
    <item>
      <title>How to post to Http Event Collector with PHP?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-post-to-Http-Event-Collector-with-PHP/m-p/474977#M81565</link>
      <description>&lt;P&gt;All, &lt;/P&gt;

&lt;P&gt;Anyone ever post to HEC using PHP? Got a working example? Or see where I am going wrong?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?php
        $ch = curl_init("https://10.x.x.x:8088/services/collector/event");
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERPWD, "x:MYTOKEN");
        curl_setopt($ch, CURLOPT_POSTFIELDS, "number=10");
        $output = curl_exec($ch);
        curl_close($ch);
        echo $output;
?&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Feb 2020 00:47:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-post-to-Http-Event-Collector-with-PHP/m-p/474977#M81565</guid>
      <dc:creator>daniel333</dc:creator>
      <dc:date>2020-02-21T00:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to post to Http Event Collector with PHP?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-post-to-Http-Event-Collector-with-PHP/m-p/474978#M81566</link>
      <description>&lt;P&gt;Got it! Trick was the formatting of the $data variable. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;// Send Data to HEC with PHP

&amp;lt;?php
        $data = "{\"event\":\"testing\",\"sourcetype\": \"st\"}";
        $ch = curl_init("https://10.x.x.x:8088/services/collector/event");
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERPWD, "x:cbmytoen");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $output = curl_exec($ch);
        curl_close($ch);
        echo $output;
?&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Feb 2020 01:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-post-to-Http-Event-Collector-with-PHP/m-p/474978#M81566</guid>
      <dc:creator>daniel333</dc:creator>
      <dc:date>2020-02-21T01:20:13Z</dc:date>
    </item>
  </channel>
</rss>

