setOption() public method

Set curl option
public setOption ( string $key, mixed $value )
$key string
$value mixed
 public function actionSend()
 {
     if (Yii::$app->request->post("recipient_id")) {
         $recipient_id = Yii::$app->request->post("recipient_id");
         $text = Yii::$app->request->post("message");
         $sender_id = Yii::$app->request->post("sender_id");
         $recipientUser = Salamiuser::find()->where(['id' => $recipient_id])->one();
         $senderUser = Salamiuser::find()->where(['id' => $sender_id])->one();
         $message = new Messages();
         $message->sender_id = $senderUser->id;
         $message->recipient_id = $recipientUser->id;
         $message->text = $text;
         $message->state = "new";
         $saved = $message->save();
         $data = array('user_ids' => array($recipientUser->facebook_id), 'notification' => array("alert" => $text, "android" => array('payload' => array("sender" => $senderUser->facebook_id))));
         $ionicAppId = "70f2a984";
         $ionicApiSecret = "ec4839bfb9ea2daa2271b0149a0c18003a3672178f4e6485";
         $url = "https://push.ionic.io/api/v1/push";
         $content = json_encode($data);
         $curl = new curl\Curl();
         $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
         $curl->setOption(CURLOPT_POSTFIELDS, $content);
         $curl->setOption(CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-Ionic-Application-Id: ' . $ionicAppId, 'Content-Length: ' . strlen($content), 'Authorization: Basic ' . base64_encode($ionicApiSecret)));
         $response = $curl->post('https://push.ionic.io/api/v1/push');
         return $response;
     }
     return '{"error": "Invalid request parameters"}';
 }
Esempio n. 2
1
 public function subscribe()
 {
     $url = Yii::$app->params['getdrip']['apiUrl'] . Yii::$app->params['getdrip']['accountId'] . '/' . 'campaigns/' . Yii::$app->params['getdrip']['signup_campaignId'] . '/subscribers';
     $subscribe = json_encode(['subscribers' => [["email" => $this->email, "utc_offset" => 660, "double_optin" => true, "starting_email_index" => 0]]]);
     $curl = new curl\Curl();
     $curl->reset();
     $curl->setOption(CURLOPT_FRESH_CONNECT, true);
     $curl->setOption(CURLOPT_FORBID_REUSE, true);
     $curl->setOption(CURLOPT_RETURNTRANSFER, true);
     $curl->setOption(CURLOPT_FOLLOWLOCATION, true);
     $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
     $curl->setOption(CURLOPT_SSL_VERIFYHOST, false);
     $curl->setOption(CURLOPT_USERPWD, Yii::$app->params['getdrip']['apiToken'] . ":" . '');
     $curl->setOption(CURLOPT_POSTFIELDS, $subscribe);
     $curl->setOption(CURLOPT_CUSTOMREQUEST, "POST");
     $curl->setOption(CURLOPT_HTTPHEADER, array('Accept:application/json, text/javascript, */*; q=0.01', 'Content-Type: application/vnd.api+json'));
     $response = $curl->post($url);
 }
Esempio n. 3
0
 public function getSprint()
 {
     $curl = new curl\Curl();
     $curl->setOption(CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'] . '/infoboard/frontend/web/cookie.txt')->setOption(CURLOPT_USERPWD, 'sga:sytuacja!generacja')->setOption(CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'] . '/infoboard/frontend/web/cookie.txt')->get('http://192.168.1.253/raporty_etl/login');
     if ($curl->responseCode == 200) {
         $response = $curl->setOption(CURLOPT_POSTFIELDS, array('nick' => 'AFR', 'password' => 'afr123'))->setOption(CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'] . '/infoboard/frontend/web/cookie.txt')->post('http://192.168.1.253/raporty_etl/login/login_do');
     }
     $response = $curl->setOption(CURLOPT_POSTFIELDS, array('getJSON' => 1))->setOption(CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'] . '/infoboard/frontend/web/cookie.txt')->post('http://192.168.1.253/raporty_etl/sprint/stats');
     $sprintData = json_decode($response, true);
     $this->data->users = [];
     $this->data->userRealization = [];
     $this->data->userRemains = [];
     $this->data->colors = [];
     $this->data->now = $sprintData['dzis'];
     $this->data->dates = $sprintData['daty'];
     $this->data->plan = $sprintData['plan'];
     $this->data->realization = $sprintData['realizacja'];
     $this->data->sprint = $sprintData['nr'];
     foreach ($sprintData['uzyt'] as $user => $data) {
         $percent = ($data['godz_wyk'] + $data['prod_godz_wyk']) / ($data['work_time'] - $data['nieobecnosci']) * 100;
         array_push($this->data->users, strtoupper($user));
         array_push($this->data->userRealization, number_format($percent, 2, '.', ''));
         array_push($this->data->userRemains, number_format(100 - $percent, 2, '.', ''));
         array_push($this->data->colors, 100 - $percent > $this->data->now + 20 ? '"#ff5555"' : '"#000000"');
     }
     return $this;
 }
Esempio n. 4
0
 public function actionAddtax()
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $curl = new curl\Curl();
     //post https://accounts.zoho.com/apiauthtoken/create?SCOPE=ZohoInvoice/invoiceapi
     $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('JSONString' => '{ "tax_name": "Verhuuren1",  "tax_percentage": 23,  "tax_type": "tax"}')))->post('https://invoice.zoho.com/api/v3/settings/taxes?authtoken=90545fa01029567ccd0ad3447cbf843c');
     return $response;
 }
Esempio n. 5
0
 /**
  * cURL multiple POST example one after one
  */
 public function actionMultipleRequest()
 {
     //Init curl
     $curl = new curl\Curl();
     //post http://example.com/
     $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('myPostField' => 'value')))->post('http://example.com/');
     //post http://example.com/, reset request before
     $response = $curl->reset()->setOption(CURLOPT_POSTFIELDS, http_build_query(array('myPostField' => 'value')))->post('http://example.com/');
 }
Esempio n. 6
0
 private function post($params)
 {
     $curl = new Curl();
     $curl->setOption(CURLOPT_POSTFIELDS, 'force=1&order[is_test]=1&order[dispatch_type]=3&order[dispatch_time]=1&order[dispatch_at]=2015-09-12&order[person]=%D0%96%D0%B5%D0%BD%D1%8F+%D0%9B%D1%83%D0%BA%D0%B0%D1%88%D0%B8%D0%BD&order[comment]=%D0%B7%D0%B0%D0%BF%D1%87%D0%B0%D1%81%D1%82%D0%B8+%D0%B4%D0%BB%D1%8F+%D0%98%D0%BF%D0%BF%D0%BE%D0%BB%D0%B8%D1%82%D0%B0&order[shipment_address]=%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0%2C+3-%D1%8F+%D1%83%D0%BB%D0%B8%D1%86%D0%B0+%D0%A1%D1%82%D1%80%D0%BE%D0%B8%D1%82%D0%B5%D0%BB%D0%B5%D0%B9%2C+%D0%B4%D0%BE%D0%BC+25%2C+%D0%BA%D0%B2%D0%B0%D1%80%D1%82%D0%B8%D1%80%D0%B0+12&order[items][1][resource_id]=703&order[items][1][warehouse_id]=46&order[items][1][quantity]=1&order[items][1][comment]=%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%BE%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9+%D0%BA%D0%BE%D0%BC%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%80%D0%B8%D0%B9+1&order[items][2][resource_id]=50716&order[items][2][warehouse_id]=46&order[items][2][quantity]=1&order[items][2][comment]=%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%BE%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9+%D0%BA%D0%BE%D0%BC%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%80%D0%B8%D0%B9+2&&order[items][3][resource_id]=50716&order[items][3][warehouse_id]=6&order[items][3][quantity]=1&order[items][3][comment]=%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%BE%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9+%D0%BA%D0%BE%D0%BC%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%80%D0%B8%D0%B9+3')->post($this->uri . '?key=' . $params['key'], false);
     //        var_dump($curl);
     //        var_dump($curl);die;
     // .'?key='.$params['key']  <- КОСТЫЛЬ
     //        return $curl;
 }
Esempio n. 7
0
 /**
  * Authorizes and returns authorization code
  * @author Adegoke Obasa <*****@*****.**>
  * @return mixed code
  * @throws Oauth2ClientException
  * @throws InvalidParamException
  */
 public function authorize()
 {
     $this->validateAuthParams();
     try {
         $response = $this->curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('grant_type' => self::GRANT_TYPE_AUTHORIZATION_CODE, 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'response_type' => self::RESPONSE_TYPE_CODE, 'state' => self::STATE_ALIVE)))->post($this->authUrl, false);
     } catch (InvalidParamException $invalidParamException) {
         throw new Oauth2ClientException($invalidParamException->getMessage());
     }
     return $this->handleAuthorizeResponse($response);
 }
 public function actionPerform()
 {
     $request = Yii::$app->request;
     $request = $request->post();
     return print_r($request['message']['chat']['id']);
     //Init curl
     $curl = new curl\Curl();
     //post http://example.com/
     $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('myPostField' => 'value')))->post('http://example.com/');
 }
Esempio n. 9
0
 /**
  * Create an item in teh UPCDatabase.org
  * 
  * @return array ('success' => true/false, 'errorText' => 'string')
  */
 public function createItem($itemDetails)
 {
     $ch = new curl\Curl();
     $response = $ch->setOption(CURLOPT_POSTFIELDS, http_build_query(['upc' => $itemDetails['upc'], 'mrsp' => $itemDetails['msrp'], 'apikey' => Yii::$app->params['apiKey'], 'title' => $itemDetails['title'], 'alias' => $itemDetails['alias'], 'description' => $itemDetails['description'], 'unit' => 'each']))->post(Yii::$app->params['apiUrl'] . '/submit/curl.php');
     if ($response == 'OK') {
         $result = ['success' => true, 'errorText' => ''];
     } else {
         $result = ['success' => false, 'errorText' => $response];
     }
     return $result;
 }
Esempio n. 10
0
 /**
  * @param array $data {
  *  @var string Login
  *  @var string Password md5 encoded password. Since md5 is not very strong hashing algorithm, https usage highly recommended.
  * }
  */
 protected function prepareRequest($data)
 {
     $isHttps = parse_url($this->url, PHP_URL_SCHEME) === 'https';
     $headers = ['Date' => (new \DateTime())->format('r'), 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept: application/json'];
     $this->curl->setOption(CURLOPT_RETURNTRANSFER, true);
     $this->curl->setOption(CURLOPT_USERAGENT, __CLASS__);
     $this->curl->setOption(CURLOPT_POSTFIELDS, $data);
     if ($isHttps) {
         $this->curl->setOption(CURLOPT_SSL_VERIFYHOST, 0);
         $this->curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
     }
     $this->curl->setOption(CURLOPT_CONNECTTIMEOUT, $this->timeout);
     $this->curl->setOption(CURLOPT_TIMEOUT, $this->timeout);
 }
Esempio n. 11
0
 /**
  * get sscode
  * @author NamDD
  * @since 1.0.0
  * @param
  * @return array ss
  */
 protected static function _api($url, $params, $method = 'post')
 {
     $curl = new curl\Curl();
     $curl->setOption(CURLOPT_HTTPHEADER, ['Content-Type:application/json']);
     if (isset(static::$api['proxy'])) {
         $curl->set_option(CURLOPT_PROXY, static::$api['proxy']);
     }
     if ($method == 'post') {
         $curl->setOption(CURLOPT_POSTFIELDS, json_encode($params, JSON_UNESCAPED_UNICODE));
     } else {
         $url = $url . '?' . http_build_query($params);
     }
     $res = $curl->{$method}($url);
     $res = json_decode($res, true);
     $status = $curl->responseCode;
     if ($status == 200) {
         \Yii::info('Api result: ' . print_r($params, true) . print_r($res, true));
         return $res;
     }
     \Yii::info('Api error: ' . print_r($params, true) . print_r($res, true));
     return [];
 }
Esempio n. 12
0
 public static function addContact($user = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $curl = new curl\Curl();
     //post https://accounts.zoho.com/apiauthtoken/create?SCOPE=ZohoInvoice/invoiceapi
     $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('JSONString' => '{  
                     "contact_name":"' . $user->profile->full_name . '",
                     "company_name": "' . $user->company->name . '",
                     "payment_terms": 15,
                     "payment_terms_label": "Net 15",
                     "currency_id": "638713000000008020",
                     "website": "www.bowmanfurniture.com"
                 }')))->post('https://invoice.zoho.com/api/v3/contacts?authtoken=90545fa01029567ccd0ad3447cbf843c');
     return;
 }
 /**
  * Shortens an URL
  * @param string $url  URL to be shortened
  * @return string  The shortened URL.
  * @throws Exception if the request fails
  */
 public function shorten($url)
 {
     $curl = new curl\Curl();
     $resp = $curl->setOption(CURLOPT_POSTFIELDS, json_encode(['longUrl' => $url]))->setOption(CURLOPT_HTTPHEADER, ['Content-Type: application/json'])->post($this->apiEndpoint);
     if ($curl->responseCode !== 200) {
         if ($resp = json_decode($curl->response)) {
             throw new Exception(sprintf('Error: %s - Response: %s', $resp->error->message, $curl->response), $resp->error->code);
         } else {
             throw new Exception('Unknown Error. Response: ' . $curl->response, $curl->responseCode);
         }
     } else {
         $resp = json_decode($resp);
         return $resp->id;
     }
     return false;
 }
Esempio n. 14
0
 /**
  * Expands an URL
  * @param string $url URL to be expanded
  * @return string|boolean  The expanded URL if the longUrl is set in the response, FALSE otherwise.
  * @throws Exception if the request fails
  */
 public function expand($url)
 {
     $curl = new Curl();
     $resp = $curl->setOption(CURLOPT_SSL_VERIFYHOST, false)->setOption(CURLOPT_SSL_VERIFYPEER, false)->get($this->apiEndpoint . 'shortUrl=' . $url);
     if ($curl->responseCode !== 200) {
         if ($resp = json_decode($curl->response)) {
             throw new Exception(sprintf('Error: %s - Response: %s', $resp->error->message, $curl->response), $resp->error->code);
         } else {
             throw new Exception('Unknown Error. Response: ' . $curl->response, $curl->responseCode);
         }
     } else {
         $resp = json_decode($resp);
         if (!empty($resp->longUrl)) {
             return $resp->longUrl;
         }
     }
     return false;
 }
Esempio n. 15
0
 public static function get_curl($url, $params)
 {
     $url .= '?' . http_build_query($params);
     $curl = new Curl();
     //        var_dump($url);die;
     $curl->setOption('CURLOPT_COOKIESESSION', true);
     return $curl->get($url);
     //        return \Yii::$app->getResponse()->redirect($url);
     //        var_dump($url);die;
     //        $myCurl = curl_init($url);
     //
     //        curl_setopt_array($myCurl, array(
     //            CURLOPT_URL => $url,
     //            CURLOPT_RETURNTRANSFER => true,
     //            CURLOPT_HEADER=>false
     //        ));
     //        $response = curl_exec($myCurl);
     //        curl_close($myCurl);
     //        return $response;
 }
 public function executeCommand($commandType, $entity, $source, $params = [], $protocol = 'http://')
 {
     if (!class_exists('\\linslin\\yii2\\curl\\Curl')) {
         throw new Exception('linslin\\yii2\\curl\\Curl is needed.');
     }
     $curl = new curl\Curl();
     $url = $protocol . $this->endpoint . strtolower($source);
     $queryString = ['apiKey=' . $this->apiKey];
     foreach ($params['GET'] as $key => $param) {
         if (!empty($param)) {
             $queryString[] = "{$key}=" . urlencode($param);
         }
     }
     $queryString = implode('&', $queryString);
     $url .= '?' . $queryString;
     Yii::trace($url, __METHOD__);
     if (!empty($params['POST'])) {
         $raw_response = $curl->setOption(CURLOPT_POSTFIELDS, json_encode(array_filter($params['POST'])))->post($url);
     } else {
         $raw_response = $curl->get($url);
     }
     if ($raw_response !== false) {
         $response = json_decode($raw_response, true);
         if ($response['Status']['Code'] !== 0) {
             throw new Exception('Code: ' . $response['Status']['Code'] . '. ' . $response['Status']['Message']);
         }
         switch ($commandType) {
             case 'COUNT':
                 return ArrayHelper::getValue($response, $this->count_path);
             case 'ALL':
                 return $response[$entity];
             case 'ONE':
                 return $response[$entity];
             case 'SAVE':
                 return $response;
         }
     } else {
         throw new Exception('Request Error with the following url: ' . $url);
     }
 }
Esempio n. 17
0
 public function actionExample()
 {
     /*$this->url = 'http://yii.com/user/myview/63';
             $curl = new Curl();
     
             $reponse = $curl->get($this->url);
     
             p($curl->responseCode);
     
     
             p($reponse);*/
     //Init curl
     $curl = new Curl();
     //get http://example.com/
     //$response = $curl->get('http://yii.com/users');
     //Init curl
     $curl = new Curl();
     //post http://example.com/
     $rs = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('ac_info' => 'test_create', 'ac_title' => 'test_create')))->post('http://yii.com/user/create');
     p($rs);
     //删除一行数据
     //$rs = $curl->delete('http://yii.com/users/14415');
 }
 /**
  * Connect to EconoSim registry websites
  */
 protected function connectToRegistries()
 {
     $AuthClients = Yii::$app->esAuthClients->getClients();
     foreach ($AuthClients as $AuthClient) {
         $parts = parse_url($AuthClient->tokenUrl);
         echo "Please provide your login details for the registry at " . $parts['host'] . "\n";
         $username = $this->prompt("Username:"******"Password:");
         $url = $AuthClient->buildAuthUrl(['redirect_uri' => null, 'display_response' => 1]);
         // Build authorization URL
         $curl = new Curl();
         $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(['LoginForm' => ['username' => $username, 'password' => $password]]))->post($url);
         $arr = Json::decode($response);
         $success = ArrayHelper::getValue($arr, 'success');
         if ($success) {
             $code = ArrayHelper::getValue($arr, 'data.code');
             $accessToken = $AuthClient->fetchAccessToken($code, ['redirect_uri' => null]);
             // Get access token
             $this->Server->addAuthClient($AuthClient);
         } else {
             echo ArrayHelper::getValue($arr, 'error.message');
         }
     }
 }
Esempio n. 19
0
 public static function fetchData($url, $apiKey = null, $timeout = 30)
 {
     $curl = new curl\Curl();
     $headers = [];
     if ($apiKey !== null) {
         $headers[] = 'X-Api-Key: ' . addslashes($apiKey) . '';
     }
     $curl->setOption(CURLOPT_CONNECTTIMEOUT, $timeout);
     $curl->setOption(CURLOPT_TIMEOUT, $timeout);
     $curl->setOption(CURLOPT_HTTPHEADER, $headers);
     try {
         $response = $curl->get($url, false);
     } catch (\Exception $e) {
         $response = null;
     }
     if (empty($response) || !is_array($response)) {
         return ['data' => false, 'error' => true, 'responseCode' => (int) $curl->responseCode];
     }
     return ['data' => $response, 'error' => false, 'responseCode' => (int) $curl->responseCode];
 }
Esempio n. 20
0
 public function deleteZoHoContact($user = null)
 {
     // \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     if ($user->userInvoice) {
         $curl = new curl\Curl();
         $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array()))->delete('https://invoice.zoho.com/api/v3/contacts/' . $user->userInvoice->zoho_contact_id . '?authtoken=90545fa01029567ccd0ad3447cbf843c');
         return $response;
     }
 }
Esempio n. 21
0
 /**
  * @param array $params [
  *  'type'=>'',         // optional parameter (see Http::ARUBA_CREDIT_TYPE_* const)
  * ]
  * @param array $return return data
  * @return bool
  */
 public function checkCredit($params = [], &$return)
 {
     $mandatoryParams = ['user', 'pass'];
     $staticParams = ['user' => $this->user, 'pass' => $this->pass];
     $params = array_merge($params, $staticParams);
     if (!array_key_exists('type', $params) && !empty($this->type)) {
         $params['type'] = $this->type;
     }
     $errors = $this->checkMandatoryParams($params, $mandatoryParams);
     if ($errors !== false) {
         $return = $errors;
         return false;
     }
     $post = http_build_query($params);
     $curl = new Curl();
     $result = $curl->setOption(CURLOPT_POSTFIELDS, $post)->post($this->urlCredit);
     Yii::info($result);
     if (preg_match($this->matchPattern, $result, $ret)) {
         if (count($ret) == 3) {
             $return = [$ret[2]];
             return $ret[1] == 'OK';
         }
     }
     return false;
 }
 /**
  * @param integer $cpid = contactperson_id
  * @param integer $a = active_dagen
  * @param integer $m = monthName
  * @throws NotFoundHttpException if the model cannot be found
  * return respons from zoho invoice creating
  */
 public function actionInv($cpid, $a, $m)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $UserInvoiceMdl = UserInvoice::findOne(['user_id' => $cpid]);
     $abonnementType = $query = UserActivities::find()->select("aktieve_dagen,full_name, monthName")->where("contactperson_id=" . $cpid . " and monthName =" . $m)->all();
     //print_r($query); exit;
     return \yii\helpers\Json::encode($query);
     exit;
     //haal contact persoon op
     $curl = new curl\Curl();
     $resp = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('')))->GET('https://invoice.zoho.com/api/v3/contacts/' . $UserInvoiceMdl->zoho_contact_id . '?authtoken=90545fa01029567ccd0ad3447cbf843c');
     $obj = json_decode($resp);
     // echo  $obj->contact->primary_contact_id; exit; //638713000000068053
     //echo $obj->contact_id; exit;
     $curl = new curl\Curl();
     $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('JSONString' => '{
                         "customer_id"="638713000000068045",
                         "template_id"="638713000000025001",
                         "line_items":[
                             {"item_id": "",
                             "name":"Jaar abonnement",
                             "item_name":"Jaar abonnement",
                             "status": "active",
                             "source": "user",
                             "is_linked_with_zohocrm": false,
                             "description": "Tarief voor P.adriaanse maand Juli 2015",
                             "rate": 0.41,
                             "quantity": 31.0,
                             "tax_id":"638713000000047019",
                             "tax_name": "BTW21","tax_percentage": 21
                             },
                             {"item_id": "",
                             "name":"Jaar abonnement",
                             "item_name":"Jaar abonnement",
                             "status": "active",
                             "source": "user",
                             "is_linked_with_zohocrm": false,
                             "description": "Tarief voor Arnord Zwagerman  Juli 2015",
                             "rate": 0.41,
                             "quantity": 28.0,
                             "tax_id":"638713000000047019",
                             "tax_name": "BTW21","tax_percentage": 21
                             }
                         ]
                         
                     }')))->POST('https://invoice.zoho.com/api/v3/invoices?authtoken=90545fa01029567ccd0ad3447cbf843c');
     return $response;
 }
Esempio n. 23
0
 public function sendSms()
 {
     $result = "";
     $user = Yii::$app->user->identity;
     if ($this->id_user != $user->id) {
         return false;
     }
     if ($this->sms == 1) {
         $url = 'https://pbc.pbsol.ru:1443/pbc.php';
         $curl = new curl\Curl();
         $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
         $phone = $this->user->phone;
         switch (strlen($phone)) {
             case 12:
                 $phone = substr($phone, 1);
                 break;
             case 11:
                 $phone = "7" . substr($phone, 1);
                 break;
             case 10:
                 $phone = "7" . substr($phone, 0);
                 break;
             default:
                 $result = "200";
                 break;
         }
         $msg = "Yasv " . $this->id;
         $params = ['product' => 'sms_yasv', 'password' => 'Acn752Mnt', 'phone' => $phone, 'price' => '1000', 'msg' => $msg];
         $url .= '?' . http_build_query($params);
         $result = $curl->get($url);
         if ($result != "100") {
             $this->sms = 2;
             $this->save();
         }
     } else {
         $result = false;
     }
     return $result;
 }
Esempio n. 24
0
 public function updateZoHoContact($user = null)
 {
     // \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $curl = new curl\Curl();
     $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('JSONString' => '{  
                         "contact_name":"' . $user->company->name . '",
                         "company_name": "' . $user->company->name . '",
                         "payment_terms": 10,
                         "payment_terms_label": "Binnen 10 dagen",
                         "currency_id": "638713000000008020",
                         "custom_fields": [
                             {
                               "index": 1,
                               "value": "' . $user->id . '"
                             },
                             {
                               "index": 2,
                               "value": "' . $user->abonnement->Abonnementtypename . '"
                             },
                          ],
                         "billing_address": {
                             "address": "' . $user->company->adress . '",
                             "city": "' . $user->company->city . '",
                             "state": "",
                             "zip": "' . $user->company->zip . '",
                             "country": "' . $user->company->country . '",
                             "fax": ""
                           },
                           "shipping_address": {
                             "address": "' . $user->company->adress . '",
                             "city": "' . $user->company->city . '",
                             "state": "",
                             "zip": "' . $user->company->zip . '",
                             "country": "' . $user->company->country . '",
                             "fax": ""
                           },
                         "contact_persons": [
                             {
                               "salutation": "",
                               "first_name": "' . $user->profile->firstname . '",
                               "last_name": "' . $user->profile->lastname . '",
                               "email": "' . $user->email . '",
                               "phone": "' . $user->company->telephone . '",
                               "mobile": "' . $user->company->telephone . '",
                               "is_primary_contact": true
                             },
                           ]
                         }')))->put('https://invoice.zoho.com/api/v3/contacts/' . $user->userinvoice->zoho_contact_id . '?authtoken=90545fa01029567ccd0ad3447cbf843c');
     return $response;
 }
Esempio n. 25
0
 /**
  * @param $url
  * @throws HttpException
  */
 public function checkUrl($url)
 {
     $curl = new curl\Curl();
     $curl->setOption(CURLOPT_SSL_VERIFYHOST, false);
     $curl->setOption(CURLOPT_FOLLOWLOCATION, true);
     $curl->setOption(CURLOPT_RETURNTRANSFER, true);
     $curl->setOption(CURLOPT_AUTOREFERER, true);
     $curl->setOption(CURLOPT_CONNECTTIMEOUT, 10);
     $curl->setOption(CURLOPT_TIMEOUT, 10);
     $curl->setOption(CURLOPT_MAXREDIRS, 10);
     $curl->setOption(CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36');
     $curl->get($url);
     if ($curl->responseCode != 200) {
         throw new HttpException(400, 'Something is wrong with your URL. Status code: ' . $curl->responseCode);
     }
 }
Esempio n. 26
0
 /**
  * Creates the base cURL object with the headers data.
  *
  * @return {@link Curl} object with the headers.
  */
 protected function createBaseCurlObject()
 {
     $curl = new curl\Curl();
     //Set headers.
     $curl->setOption(CURLOPT_HTTPHEADER, $this->createHeaders());
     //Override verification of SSL.
     $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
     return $curl;
 }