0

I am very new to salesforce and trying to invoke a webservice of Echo sign through my php plugin

I am set up a connected app and used oAuth2 to get a token and I am getting it for sure. Great.

Now adobe said I have to use this string:

https://<instance_name>.salesforce.com/services/apexrest/echosign_dev1/template/load/<template_id>?masterId=<master_id>&varName1=var
Value1&varName2=varValue2

Now I am usiing php access it on form submission but no luck:

    $access_token = $_SESSION['access_token'];
     $sf_sig = 'https://myinstance.salesforce.com/services/apexrest/echosign_dev1/template/load/a1t31000002HmjV&email='.$ch_register_email;

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

            //set the url, number of POST vars, POST data
            curl_setopt($ch,CURLOPT_URL,$url);
            curl_setopt($ch,CURLOPT_POST,count($fields));
            curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

            curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch,CURLOPT_FOLLOWLOCATION, TRUE);

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

        //add the two handles
        curl_multi_add_handle($mh,$ch);
        curl_multi_add_handle($mh,$ch2);

        $active = null;
        //execute the handles
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);

        while ($active && $mrc == CURLM_OK) {
            if (curl_multi_select($mh) != -1) {
                do {
                    $mrc = curl_multi_exec($mh, $active);
                } while ($mrc == CURLM_CALL_MULTI_PERFORM);
            }
        }

        //close the handles
        curl_multi_remove_handle($mh, $ch);
        curl_multi_remove_handle($mh, $ch2);
        curl_multi_close($mh);

The first curl (ch) is working but not the second (ch2).

  • How exactly is it "not working" Do you have an error message from the call ch2 that you can share? – Mark Pond Mar 10 '16 at 19:51
  • The template is not being sent. I used chrome php to log anything and didnt see any errors. Do you see anything blatent in why this wouldnt work? Does the access token not work as the session id? Does the curl header work? – Packy Mar 10 '16 at 21:01
  • The /apexrest/ in the REST URL makes me think you have an Apex class that is urlMapping to echosign_dev1. If so, you should be able to use the Salesforce debug log to see how the request is being processed. Try opening the developer console when you make the API call and then look for the generated log. – Daniel Ballinger Mar 10 '16 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.