繁体   English   中英

PHP curl头通过认证

[英]php curl header pass authentication

我正在尝试将会话ID传递给销售人员以获取Adobe插件。 我不熟悉卷发,所以不确定是否正确:

$sf_sig = 'https://na25.salesforce.com/services/apexrest/echosign_dev1/template/load/a1t31000002HmjV&email=' . $email;

        //open connection
        $ch = curl_init();
        $ch2 = curl_init();

        //ch2 
        curl_setopt($ch2, CURLOPT_URL, $sf_sig);
        curl_setopt($ch2, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $access_token));

当Adobe声明我需要使用带有会话ID的URL时,这是否正确? 关于如何设置标题供认了。

这可能会对您有所帮助,它是此出色的Salesforce API类的一部分: https : //github.com/jahumes/salesforce-rest-api-php-wrapper/blob/master/SalesforceAPI.php

// Set the Authorization header
$request_headers = array(
    'Authorization' => 'Bearer ' . $this->access_token
);

...

curl_setopt($this->handle, CURLOPT_HTTPHEADER, $this->createCurlHeaderArray($request_headers));

他有一个像这样的函数来创建标题字符串...

/**
 * Makes the header array have the right format for the Salesforce API
 *
 * @param  $headers
 * @return array
 */
private function createCurlHeaderArray($headers) {

    $curl_headers = array();
    // Create the header array for the request
    foreach($headers as $key => $header) {
        $curl_headers[] = $key . ': ' . $header;
    }
    return $curl_headers;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM