卷曲不发送图像附件

时间:2014-09-11 06:27:59

标签: php file curl file-upload

$accessToken = 'ZDJjNDRlZDIwNDVhYzIxYzAyZDQxYzNkMDJmODdmZDc4MTQzYzA5MWFjOTk4NDE1MjUyZWMxYjUwMGUzNmE4ZQ';
$headers = array("Authorization: Bearer ". $accessToken);
$uploadfile="images/a.png"; 
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => 'https://www.abc.be/api/entranceticket/create',
    CURLOPT_POST => 1,
    CURLOPT_SSL_VERIFYHOST => FALSE,
    CURLOPT_SSL_VERIFYPEER => FALSE,
    CURLOPT_POSTFIELDS => array(
    'api_entrance_ticket[productName]' => 'Event1',
    'api_entrance_ticket[reference]' => 'M1-1',
    'api_entrance_ticket[description]' => 'Event1',
    'api_entrance_ticket[price]' => '5',
    'api_entrance_ticket[shop]' => 'SJK305801',
    'api_entrance_ticket[ticketWindowOpening]' => '2014-09-03 00:00:00',
    'api_entrance_ticket[ticketWindowClosing]' => '2014-09-23 23:59:00',
    'api_entrance_ticket[isNumbered]' => '1',
    'api_entrance_ticket[image]' => '@'.$uploadfile ,
    'api_entrance_ticket[sizeX]' => '10',
    'api_entrance_ticket[sizeY]' => '8'
    )

));


// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
if(!curl_exec($curl)){
    die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
}
curl_close($curl);

echo $resp;

在托管api所有者时使用此脚本一切正常。当我们在托管中使用它来向api发送数据时,不会发送图像。他们收到卷曲电话,但拒绝它,因为没有图像。

知道为什么这不适合我们吗?

请勿查看SSL FALSE,我们正在连接到非安全的测试环境。

编辑:改为'@@.$uploadfile

0 个答案:

没有答案