Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data = array("grant_type" => "password", "client_id" => "*********************************","client_secret"=>"************","username" =>"*********","password" => "**************");
- $data_string = json_encode($data);
- $url='https://login.salesforce.com/services/oauth2/token';
- $ch = curl_init('https://login.salesforce.com/services/oauth2/token');
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
- curl_setopt($ch, CURLOPT_HEADER,true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
- curl_setopt($ch,CURLOPT_VERBOSE,true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($data_string))
- );
- $result = curl_exec($ch);
- if($result === false)
- {
- echo 'Curl error: ' . curl_error($ch);
- }
- else
- {
- echo 'Operation completed without any errors';
- }
- $info = curl_getinfo($ch);
- echo curl_getinfo($ch);
- echo $info['access_token'];
- echo curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
- $result1= file_get_contents($url);
- var_dump(json_decode($result1, true));
- }
- ?>
- <?php
- require_once 'configPWFlow.php';
- session_start();
- $token_url = LOGIN_URI . "/services/oauth2/token";
- $params = "grant_type=password"
- . "&client_id=" . CLIENT_ID
- . "&client_secret=" . CLIENT_SECRET
- . "&username=" . USERNAME
- . "&password=" . PASSWORD;
- $curl = curl_init($token_url);
- curl_setopt($curl, CURLOPT_HEADER, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
- $json_response = curl_exec($curl);
- ...
- ?>
Add Comment
Please, Sign In to add comment