Skip to content

Instantly share code, notes, and snippets.

@mariano-aguero
Created December 14, 2015 17:46
Show Gist options
  • Save mariano-aguero/579ae55b5cb21064b729 to your computer and use it in GitHub Desktop.
Save mariano-aguero/579ae55b5cb21064b729 to your computer and use it in GitHub Desktop.
Phonegap File Upload
<?php
# replace PATH_TO_BUILD, USERNAME, PASSWORD and TITLE_EXAMPLE
$zipname = 'PATH_TO_BUILD/build.zip';
$data = ['file' => new CurlFile($zipname),
'data' => json_encode(['title' => 'TITLE_EXAMPLE' ,'create_method' => 'file'])
];
$myusername = 'USERNAME';
$password = 'PASSWORD';
$handle = curl_init();
curl_setopt($handle, CURLOPT_USERPWD, $myusername.':'.$password);
curl_setopt($handle, CURLOPT_URL, "https://build.phonegap.com/api/v1/apps");
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_HTTPHEADER,['Content-type: multipart/form-data;']);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($handle);
print_r($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment