1 <?php 2 3 function getNewToken(){ 4 try{ 5 $url = 'https://login.salesforce.com/services/oauth2/token'; 6 $fields = array( 7 'grant_type' => "refresh_token", 8 'client_id' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 9 'client_secret' => "xxxxxxxxxxx", 10 'refresh_token' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" 11 ); 12 13 14 foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } 15 16 $ch = curl_init($url); 17 18 //set the url, number of POST vars, POST data 19 curl_setopt($ch,CURLOPT_POST, true); 20 curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); 21 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 22 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 23 24 //execute post 25 $result = curl_exec($ch); 26 27 //close connection 28 curl_close($ch); 29 30 $json_a=json_decode($result,true); 31 32 return $json_a; 33 }catch(Exception $e){ 34 var_dump($e); 35 } 36 } 37 ?>