src/Client/WiziSignClient.php line 616

Open in your IDE?
  1. <?php
  2. namespace App\Client;
  3. class WiziSignClient
  4. {
  5. private $apikey;
  6. private $apiBaseUrl;
  7. private $apiBaseUrlWslash;
  8. private $idfile;
  9. private $idAdvProc;
  10. private $member;
  11. private $fileobject;
  12. /**
  13. * WiziSignClient constructor.
  14. * @param $apikey
  15. * @param $mode
  16. */
  17. public function __construct($apikey,$mode)
  18. {
  19. $this->setApikey($apikey);
  20. if($mode == 'prod'){
  21. $this->apiBaseUrl = 'https://api.yousign.com/';
  22. $this->apiBaseUrlWslash = 'https://api.yousign.com';
  23. }else{
  24. $this->apiBaseUrl = 'https://staging-api.yousign.com/';
  25. $this->apiBaseUrlWslash = 'https://staging-api.yousign.com';
  26. }
  27. }
  28. /**
  29. * @return string
  30. */
  31. public static function world()
  32. {
  33. return "Client pour l'api Yousign";
  34. }
  35. /**
  36. * @param $apikey
  37. */
  38. public function setApikey($apikey){
  39. $this->apikey = $apikey;
  40. }
  41. /**
  42. * @return mixed
  43. */
  44. public function getApikey(){
  45. return $this->apikey;
  46. }
  47. /**
  48. * @param $apikey
  49. */
  50. public function setMember($member){
  51. $this->member = $member;
  52. }
  53. /**
  54. * @return mixed
  55. */
  56. public function getMember(){
  57. return $this->member;
  58. }
  59. /**
  60. * @return mixed
  61. */
  62. public function getIdfile(){
  63. return $this->idfile;
  64. }
  65. /**
  66. * @param $idfile
  67. */
  68. public function setIdfile($idfile){
  69. $this->idfile = $idfile;
  70. }
  71. /**
  72. * permet de recup le fichier signé sur yousign
  73. * @param $fileid
  74. * @param $mode
  75. * @return bool|string
  76. */
  77. public function downloadSignedFile($fileid,$mode){
  78. $curl = curl_init();
  79. if($mode == 'binary'){
  80. $urlstr = $this->apiBaseUrlWslash.$fileid."/download?alt=media";
  81. }else{
  82. $urlstr = $this->apiBaseUrlWslash.$fileid."/download";
  83. }
  84. curl_setopt_array($curl, array(
  85. CURLOPT_URL => $urlstr,
  86. CURLOPT_RETURNTRANSFER => true,
  87. CURLOPT_ENCODING => "",
  88. CURLOPT_MAXREDIRS => 10,
  89. CURLOPT_TIMEOUT => 0,
  90. CURLOPT_FOLLOWLOCATION => false,
  91. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  92. CURLOPT_CUSTOMREQUEST => "GET",
  93. CURLOPT_HTTPHEADER => array(
  94. "Authorization: Bearer ".$this->getApikey(),
  95. "Content-Type: application/json"
  96. ),
  97. ));
  98. $response = curl_exec($curl);
  99. $err = curl_error($curl);
  100. curl_close($curl);
  101. if ($err) {
  102. return "cURL Error #:" . $err;
  103. } else {
  104. return $response;
  105. }
  106. }
  107. /**
  108. * permet de recup la preuve de mandat sur yousign
  109. * @param $fileid
  110. * @return bool|string
  111. */
  112. public function downloadProofFile($procedureId){
  113. $curl = curl_init();
  114. $urlstr = $this->apiBaseUrlWslash.'/procedures/'.$procedureId.'/proof';
  115. curl_setopt_array($curl, array(
  116. CURLOPT_URL => $urlstr,
  117. CURLOPT_RETURNTRANSFER => true,
  118. CURLOPT_ENCODING => "",
  119. CURLOPT_MAXREDIRS => 10,
  120. CURLOPT_TIMEOUT => 0,
  121. CURLOPT_FOLLOWLOCATION => false,
  122. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  123. CURLOPT_CUSTOMREQUEST => "GET",
  124. CURLOPT_HTTPHEADER => array(
  125. "Authorization: Bearer ".$this->getApikey(),
  126. "Content-Type: application/json"
  127. ),
  128. ));
  129. $response = curl_exec($curl);
  130. $err = curl_error($curl);
  131. curl_close($curl);
  132. if ($err) {
  133. return "cURL Error #:" . $err;
  134. } else {
  135. return $response;
  136. }
  137. }
  138. /**
  139. * @param $post
  140. * @param $action
  141. * @param $method
  142. * @return mixed|string
  143. */
  144. public function api_request( $post,$action,$method) {
  145. header('Content-Type: application/json'); // Specify the type of data
  146. $ch = curl_init($this->apiBaseUrl.$action); // Initialise cURL
  147. $post = json_encode($post); // Encode the data array into a JSON string
  148. $authorization = "Authorization: Bearer ".$this->getApikey(); // Prepare the authorisation token
  149. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization )); // Inject the token into the header
  150. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  151. if($method == 'POST'){
  152. curl_setopt($ch, CURLOPT_POST, 1); // Specify the request method as POST
  153. curl_setopt($ch, CURLOPT_POSTFIELDS, $post); // Set the posted fields
  154. }
  155. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // This will follow any redirects
  156. $result = curl_exec($ch); // Execute the cURL statement
  157. $err = curl_error($ch);
  158. curl_close($ch); // Close the cURL connection
  159. if ($err) {
  160. return "cURL Error #:" . $err;
  161. } else {
  162. return json_decode($result);
  163. }
  164. // Return the received data
  165. }
  166. /**
  167. * @return mixed|string
  168. */
  169. public function getUsers(){
  170. $users = $this->api_request(array(),'users','GET');
  171. return $users;
  172. }
  173. /**
  174. * @param $filepath
  175. * @return $this
  176. */
  177. public function newProcedure($filepath){
  178. $curl = curl_init();
  179. $data = file_get_contents($filepath);
  180. $b64Doc = base64_encode($data);
  181. $post = array(
  182. 'name' => 'test.pdf',
  183. 'content' => $b64Doc
  184. );
  185. $p = json_encode($post);
  186. curl_setopt_array($curl, array(
  187. CURLOPT_URL => $this->apiBaseUrl."files",
  188. CURLOPT_RETURNTRANSFER => true,
  189. CURLOPT_ENCODING => "",
  190. CURLOPT_MAXREDIRS => 10,
  191. CURLOPT_TIMEOUT => 0,
  192. CURLOPT_FOLLOWLOCATION => false,
  193. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  194. CURLOPT_CUSTOMREQUEST => "POST",
  195. CURLOPT_POSTFIELDS =>$p,
  196. CURLOPT_HTTPHEADER => array(
  197. "Authorization: Bearer ".$this->getApikey(),
  198. "Content-Type: application/json"
  199. ),
  200. ));
  201. $response = curl_exec($curl);
  202. $err = curl_error($curl);
  203. curl_close($curl);
  204. $rtab = json_decode($response,true);
  205. $this->idfile = $rtab['id'];
  206. return $this;
  207. }
  208. /**
  209. * @param $members
  210. * @param $titresignature
  211. * @param $description
  212. * @return bool|string
  213. */
  214. public function addMembersOnProcedure($members,$titresignature,$description){
  215. $post2 = array(
  216. 'name' => $titresignature,
  217. 'description' => $description,
  218. 'members'=> $members
  219. );
  220. $p2 = json_encode($post2,true);
  221. $curl = curl_init();
  222. curl_setopt_array($curl, array(
  223. CURLOPT_URL => $this->apiBaseUrl."procedures",
  224. CURLOPT_RETURNTRANSFER => true,
  225. CURLOPT_ENCODING => "",
  226. CURLOPT_MAXREDIRS => 10,
  227. CURLOPT_TIMEOUT => 0,
  228. CURLOPT_FOLLOWLOCATION => false,
  229. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  230. CURLOPT_CUSTOMREQUEST => "POST",
  231. CURLOPT_POSTFIELDS => $p2,
  232. CURLOPT_HTTPHEADER => array(
  233. "Authorization: Bearer ".$this->getApikey(),
  234. "Content-Type: application/json"
  235. ),
  236. ));
  237. $response = curl_exec($curl);
  238. $err = curl_error($curl);
  239. curl_close($curl);
  240. return $response;
  241. }
  242. /**
  243. * @param $parameters
  244. * @param bool $notifmail
  245. * @param bool $webhook
  246. * @param string $webhookMethod
  247. * @param string $webhookUrl
  248. * @param string $webhookHeader
  249. * @return bool|string
  250. */
  251. public function AdvancedProcedureCreate($parameters,$webhook = false,$webhookMethod = '',$webhookUrl = '',$webhookHeader = ''){
  252. /*
  253. *
  254. {
  255. "name": "My procedure",
  256. "description": "Description of my procedure with advanced mode",
  257. "start" : false
  258. }
  259. */
  260. $conf = array();
  261. /*
  262. $conf["email"] =
  263. array(
  264. "procedure.started" => array(
  265. array(
  266. "subject" => "Flash Énergie: un document est en attente de signature",
  267. "message" => "Bonjour <tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> <tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag>, <br><br> Un document est en attente de signature pour votre dossier énergie Flash Consulting, veuillez cliquer sur le lien suivant pour lire le document et le signer: <br><br> <tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Accéder aux documents\">Accéder au document</tag>",
  268. "to" => ["@members"]
  269. )
  270. )
  271. )
  272. ;
  273. */
  274. if($webhook == true){
  275. $conf["webhook"] = array(
  276. "procedure.finished" => array(
  277. array(
  278. "url" => $webhookUrl,
  279. "method" => $webhookMethod,
  280. "headers" => array(
  281. "X-Flash-Data-Header" => $webhookHeader
  282. )
  283. )
  284. )
  285. );
  286. }
  287. $parameters['config'] = $conf;
  288. $curl = curl_init();
  289. $params = json_encode($parameters,true);
  290. curl_setopt_array($curl, array(
  291. CURLOPT_URL => $this->apiBaseUrl."procedures",
  292. CURLOPT_RETURNTRANSFER => true,
  293. CURLOPT_ENCODING => "",
  294. CURLOPT_MAXREDIRS => 10,
  295. CURLOPT_TIMEOUT => 0,
  296. CURLOPT_FOLLOWLOCATION => false,
  297. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  298. CURLOPT_CUSTOMREQUEST => "POST",
  299. CURLOPT_POSTFIELDS => $params,
  300. CURLOPT_HTTPHEADER => array(
  301. "Authorization: Bearer ".$this->getApikey(),
  302. "Content-Type: application/json"
  303. ),
  304. ));
  305. $response = curl_exec($curl);
  306. $err = curl_error($curl);
  307. curl_close($curl);
  308. if ($err) {
  309. return "cURL Error #:" . $err;
  310. } else {
  311. $rtab = json_decode($response,true);
  312. $this->idAdvProc = $rtab['id'];
  313. return $response;
  314. }
  315. }
  316. /**
  317. * @param $filepath
  318. * @param $namefile
  319. * @return bool|string
  320. */
  321. public function AdvancedProcedureAddFile($filepathOrFileContent,$namefile,$filecontent = false){
  322. /*
  323. {
  324. "name": "Name of my signable file.pdf",
  325. "content": "JVBERi0xLjUKJb/3ov4KNiA [...] VPRgo=",
  326. "procedure": "/procedures/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  327. }
  328. */
  329. if($filecontent == false){
  330. $data = file_get_contents($filepathOrFileContent);
  331. $b64Doc = base64_encode($data);
  332. }else{
  333. $b64Doc = base64_encode($filepathOrFileContent);
  334. }
  335. $parameters = array(
  336. 'name' => $namefile,
  337. 'content' => $b64Doc,
  338. 'procedure' => $this->idAdvProc
  339. );
  340. $curl = curl_init();
  341. $params = json_encode($parameters,true);
  342. curl_setopt_array($curl, array(
  343. CURLOPT_URL => $this->apiBaseUrl."files",
  344. CURLOPT_RETURNTRANSFER => true,
  345. CURLOPT_ENCODING => "",
  346. CURLOPT_MAXREDIRS => 10,
  347. CURLOPT_TIMEOUT => 0,
  348. CURLOPT_FOLLOWLOCATION => false,
  349. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  350. CURLOPT_CUSTOMREQUEST => "POST",
  351. CURLOPT_POSTFIELDS => $params,
  352. CURLOPT_HTTPHEADER => array(
  353. "Authorization: Bearer ".$this->getApikey(),
  354. "Content-Type: application/json"
  355. ),
  356. ));
  357. $response = curl_exec($curl);
  358. $err = curl_error($curl);
  359. curl_close($curl);
  360. if ($err) {
  361. return "cURL Error #:" . $err;
  362. } else {
  363. $rtab = json_decode($response,true);
  364. $this->idfile = $rtab['id'];
  365. return $response;
  366. }
  367. }
  368. /**
  369. * @param $firstname
  370. * @param $lastname
  371. * @param $email
  372. * @param $phone
  373. * @return bool|string
  374. */
  375. public function AdvancedProcedureAddMember($firstname,$lastname,$email,$phone){
  376. /*
  377. {
  378. "firstname": "John",
  379. "lastname": "Doe",
  380. "email": "john.doe@yousign.fr",
  381. "phone": "+33612345678",
  382. "procedure": "/procedures/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  383. }
  384. */
  385. $member = array(
  386. "firstname" => $firstname,
  387. "lastname" => $lastname,
  388. "email" => $email,
  389. "phone" => $phone,
  390. "procedure" => $this->idAdvProc
  391. );
  392. $curl = curl_init();
  393. $param = json_encode($member,true);
  394. curl_setopt_array($curl, array(
  395. CURLOPT_URL => $this->apiBaseUrl."members",
  396. CURLOPT_RETURNTRANSFER => true,
  397. CURLOPT_ENCODING => "",
  398. CURLOPT_MAXREDIRS => 10,
  399. CURLOPT_TIMEOUT => 0,
  400. CURLOPT_FOLLOWLOCATION => false,
  401. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  402. CURLOPT_CUSTOMREQUEST => "POST",
  403. CURLOPT_POSTFIELDS =>$param,
  404. CURLOPT_HTTPHEADER => array(
  405. "Authorization: Bearer ".$this->getApikey(),
  406. "Content-Type: application/json"
  407. ),
  408. ));
  409. $response = curl_exec($curl);
  410. $err = curl_error($curl);
  411. curl_close($curl);
  412. if ($err) {
  413. return "cURL Error #:" . $err;
  414. } else {
  415. $rtab = json_decode($response,true);
  416. $this->member = $rtab['id'];
  417. return $response;
  418. }
  419. }
  420. /**
  421. * @param $position
  422. * @param $page
  423. * @param $mention
  424. * @param $mention2
  425. * @param $reason
  426. * @return bool|string
  427. */
  428. public function AdvancedProcedureFileObject($position,$page,$mention,$mention2,$reason){
  429. /*
  430. {
  431. "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  432. "member": "/members/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  433. "position": "230,499,464,589",
  434. "page": 2,
  435. "mention": "Read and approved",
  436. "mention2": "Signed by John Doe",
  437. "reason": "Signed by John Doe (Yousign)"
  438. }
  439. */
  440. $parameter = array(
  441. "file"=> $this->idfile,
  442. "member"=> $this->member,
  443. "position"=> $position,
  444. "page"=> $page,
  445. "mention"=> $mention,
  446. "mention2"=> $mention2,
  447. "reason"=> $reason
  448. );
  449. $param = json_encode($parameter,true);
  450. $curl = curl_init();
  451. curl_setopt_array($curl, array(
  452. CURLOPT_URL => $this->apiBaseUrl."file_objects",
  453. CURLOPT_RETURNTRANSFER => true,
  454. CURLOPT_ENCODING => "",
  455. CURLOPT_MAXREDIRS => 10,
  456. CURLOPT_TIMEOUT => 0,
  457. CURLOPT_FOLLOWLOCATION => false,
  458. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  459. CURLOPT_CUSTOMREQUEST => "POST",
  460. CURLOPT_POSTFIELDS => $param,
  461. CURLOPT_HTTPHEADER => array(
  462. "Authorization: Bearer ".$this->getApikey(),
  463. "Content-Type: application/json"
  464. ),
  465. ));
  466. $response = curl_exec($curl);
  467. $err = curl_error($curl);
  468. curl_close($curl);
  469. if ($err) {
  470. echo "cURL Error #:" . $err;
  471. } else {
  472. $rtab = json_decode($response,true);
  473. $this->fileobject = $rtab['id'];
  474. return $response;
  475. }
  476. }
  477. /**
  478. * @return bool|string
  479. */
  480. public function AdvancedProcedurePut(){
  481. /*
  482. {
  483. "start": true
  484. }
  485. */
  486. $curl = curl_init();
  487. curl_setopt_array($curl, array(
  488. CURLOPT_URL => $this->apiBaseUrlWslash."".$this->idAdvProc,
  489. CURLOPT_RETURNTRANSFER => true,
  490. CURLOPT_ENCODING => "",
  491. CURLOPT_MAXREDIRS => 10,
  492. CURLOPT_TIMEOUT => 0,
  493. CURLOPT_FOLLOWLOCATION => false,
  494. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  495. CURLOPT_CUSTOMREQUEST => "PUT",
  496. CURLOPT_POSTFIELDS =>"{\n \"start\": true\n}",
  497. CURLOPT_HTTPHEADER => array(
  498. "Authorization: Bearer ".$this->getApikey(),
  499. "Content-Type: application/json"
  500. ),
  501. ));
  502. $response = curl_exec($curl);
  503. $err = curl_error($curl);
  504. curl_close($curl);
  505. if ($err) {
  506. return "cURL Error #:" . $err;
  507. } else {
  508. return $response;
  509. }
  510. }
  511. /**
  512. * @param array $members
  513. * @param string $ProcName
  514. * @param string $ProcDesc
  515. * @param $mailsubject
  516. * @param $mailMessage
  517. * @param array $arrayTo
  518. * @return bool|string
  519. */
  520. public function addMemberWhithMailNotif($members = array(),$ProcName = '',$ProcDesc = '', $mailsubject, $mailMessage, $arrayTo = array("@creator", "@members") ){
  521. $curl = curl_init();
  522. /*
  523. * param 1 an array of members
  524. [
  525. {
  526. "firstname": "John",
  527. "lastname": "Doe",
  528. "email": "john.doe@yousign.fr",
  529. "phone": "+33612345678",
  530. "fileObjects": [
  531. {
  532. "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  533. "page": 2,
  534. "position": "230,499,464,589",
  535. "mention": "Read and approved",
  536. "mention2": "Signed by John Doe"
  537. }
  538. ]
  539. }
  540. ]
  541. */
  542. $conf = array();
  543. $conf["email"] =
  544. array(
  545. "member.started" => array(
  546. array(
  547. "subject" => $mailsubject,
  548. "message" => "Hello",
  549. "to" => array("@member")
  550. )
  551. ),
  552. "procedure.started" => array(
  553. array(
  554. "subject" => $mailsubject,
  555. "message" => $mailMessage,
  556. "to" => $arrayTo
  557. )
  558. )
  559. )
  560. ;
  561. $body = array(
  562. "name" => $ProcName,
  563. "description" => $ProcDesc,
  564. "members" => $members,
  565. "config" => $conf
  566. );
  567. $param = json_encode($body,true);
  568. curl_setopt_array($curl, array(
  569. CURLOPT_URL => $this->apiBaseUrl."procedures",
  570. CURLOPT_RETURNTRANSFER => true,
  571. CURLOPT_ENCODING => "",
  572. CURLOPT_MAXREDIRS => 10,
  573. CURLOPT_TIMEOUT => 0,
  574. CURLOPT_FOLLOWLOCATION => false,
  575. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  576. CURLOPT_CUSTOMREQUEST => "POST",
  577. CURLOPT_POSTFIELDS =>$param,
  578. CURLOPT_HTTPHEADER => array(
  579. "Authorization: Bearer ".$this->getApikey(),
  580. "Content-Type: application/json"
  581. ),
  582. ));
  583. $response = curl_exec($curl);
  584. $err = curl_error($curl);
  585. curl_close($curl);
  586. if ($err) {
  587. return "cURL Error #:" . $err;
  588. } else {
  589. return $response;
  590. }
  591. }
  592. /**
  593. * @param $filepath
  594. * @param $namefile
  595. * @return bool|string
  596. */
  597. public function AdvancedProcedureAddAttachement($filepath,$namefile){
  598. /*
  599. {
  600. "name": "Name of my attachment.pdf",
  601. "content": "JVBERi0xLjUKJb/3ov4KICA[...]VPRgo=",
  602. "procedure": "/procedures/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  603. "type": "attachment"
  604. }
  605. */
  606. $data = file_get_contents($filepath);
  607. $b64Doc = base64_encode($data);
  608. $parameters = array(
  609. 'name' => $namefile,
  610. 'content' => $b64Doc,
  611. 'procedure' => $this->idAdvProc,
  612. "type"=> "attachment"
  613. );
  614. $param = json_encode($parameters,true);
  615. $curl = curl_init();
  616. curl_setopt_array($curl, array(
  617. CURLOPT_URL => $this->apiBaseUrl."files",
  618. CURLOPT_RETURNTRANSFER => true,
  619. CURLOPT_ENCODING => "",
  620. CURLOPT_MAXREDIRS => 10,
  621. CURLOPT_TIMEOUT => 0,
  622. CURLOPT_FOLLOWLOCATION => false,
  623. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  624. CURLOPT_CUSTOMREQUEST => "POST",
  625. CURLOPT_POSTFIELDS => $param,
  626. CURLOPT_HTTPHEADER => array(
  627. "Authorization: Bearer ".$this->getApikey(),
  628. "Content-Type: application/json"
  629. ),
  630. ));
  631. $response = curl_exec($curl);
  632. $err = curl_error($curl);
  633. curl_close($curl);
  634. if ($err) {
  635. return "cURL Error #:" . $err;
  636. } else {
  637. return $response;
  638. }
  639. }
  640. /**
  641. * @param $fileId
  642. * @return bool|string
  643. */
  644. public function getFileContent($fileId){
  645. $curl = curl_init();
  646. curl_setopt_array($curl, array(
  647. CURLOPT_URL => $this->apiBaseUrlWslash.$fileId."/download?alt=media",
  648. CURLOPT_RETURNTRANSFER => true,
  649. CURLOPT_ENCODING => '',
  650. CURLOPT_MAXREDIRS => 10,
  651. CURLOPT_TIMEOUT => 0,
  652. CURLOPT_FOLLOWLOCATION => true,
  653. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  654. CURLOPT_CUSTOMREQUEST => 'GET',
  655. CURLOPT_HTTPHEADER => array(
  656. "Authorization: Bearer ".$this->getApikey(),
  657. "Content-Type: application/json"
  658. ),
  659. ));
  660. $response = curl_exec($curl);
  661. $err = curl_error($curl);
  662. curl_close($curl);
  663. if ($err) {
  664. return "cURL Error #:" . $err;
  665. } else {
  666. return $response;
  667. }
  668. }
  669. }