Php curl not working for push data in dataset


#1

Hi Team,

I need your help. I am trying to push data in data set using php curl but data push not working. Please check my below code.

$ch = curl_init('https://api.geckoboard.com/datasets/articledata.by_day/data');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = ( array('article_published' => 5,'article_submitted' => 5,'article_draft' => 5,'article_waiting' => 5,'article_scheduled' => 5,'new_users' => 5,"date"=> "2017-06-10T12:00:00Z" ) );


$data = json_encode($data);
curl_setopt($ch, CURLOPT_POST, 1); 

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_USERPWD, "7c33b18e8dc8a0be5a639532d4e1c3b6:");
//curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$headers[] = 'Content-Type: application/json';
$headers[] = 'Content-Length: 10000';
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'data='.$data);

$response = curl_exec($ch);
$headers = curl_getinfo($ch);

Please check.


#2

Hi Jeff,

I can see that you’ve also asked us a few questions about Datasets through our chat system. I’m not sure whether this is part of those issues or a separate issue and, as you asked this over the weekend and have raised new questions since, there’s a chance that you have resolved this already.

If you are still having problems with this particular data push, please can you let me know what error message you’re seeing returned?

Please can you also share the schema that you’re using for this data - how you created the dataset using PUT? This will help to check that it is shaped correctly for your data.

Thanks!

Lisa