scraping data from truecaller - web-scraping

I have 200K phone number and i want to get there city using truecaller , how to do that ?
as you know truecaller has a restriction per requests ,,
somebody do this here :
https://www.phphive.info/324/truecaller-api/
this is mycode :
$cookieFile = dirname(__file__) . DIRECTORY_SEPARATOR . 'cookies';
$no = $users[0];
$url = "https://www.truecaller.com/api/search?type=4&countryCode=sd&q=" . $no;
$ch = curl_init();
$header = array();
$header[] = 'Content-length: 0';
$header[] = 'Content-type: application/json';
$header[] = 'Authorization: Bearer i03~CNORR-VIOJ2k~Hua_GBt73sKJJmO';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
$data = json_decode($data, true);
$name = $data['data'][0]['name'];
$altname = $data['data'][0]['altName'];
$gender = $data['data'][0]['gender'];
$about = $data['data'][0]['about'];

try my npm package truecallerjs
https://www.npmjs.com/package/truecallerjs
const truecallerjs = require('truecallerjs');
var countryCode = "IN"; // Default country code to use.
var installationId = "YOUR INSTALLATION ID";
var phoneNumbers = "+919912345678,+14051234567,+919987654321....." // Phone numbers seperated by comma's
const searchResult = truecallerjs.bulkSearch(phoneNumbers,countryCode,installationId)
searchResult.then(function (response) {
for (let i = 0; i < response.data.length; i++) {
if("undefined" === typeof response.data[i].value.addresses[0].city ) {
console.log(`${response.data[i].key} => Unkown city`);
} else {
console.log(`${response.data[i].key} => `,response.data[i].value.addresses[0].city);
}
}
})
// OUTPUT
// +919912345678 => Andhra Pradesh
// +14051234567 => Unkown city
// +919987654321 => Mumbai
// ...
// ...

Related

I want to add contact form 7 data to zoho crm with custom code in wordpress. I tried but not find any solution

I already added the code on my function.php file by applying zoho crm api but the data is not transferring on ZOHO crm.
I called the data through the access token provided by Zoho crm, then i create API v2 of web API and generate client id and client secret. I don't know where i am making error
Please check and update me where i am making mistake
add_action('wpcf7_mail_sent','brainium_cf7_api_sender');
function brainium_cf7_api_sender(){
$title = $contact_form->title;
if( $title === 'Contact form 1') {
$submission = WPCF7_Submission::get_instance();
if( $submission ){
$posted_data = $submission->get_posted_data();
$first_name = $posted_data['first-name'];
$last_name = $posted_data['last-name'];
$email = $posted_data['your-email'];
$phone = $posted_data['Phone-no'];
$message = $posted_data['your-message'];
$budget = $posted_data['budget'];
$checkbox = $posted_data['checkbox-993'];
$auth = 'xxxxxxxxxxxx';
$refreshToken = "xxxxxxxxxxxx";
//get the last date and time of refresh token generation
//get the access token
$url = "https://accounts.zoho.com/oauth/v2/token";
$query = "refresh_token=xxxxxxxxxxxx&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxxxxx&grant_type=refresh_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$result = curl_exec($ch);
curl_close($ch);
//get the token from the JSON in result
$accessToken = json_decode($result, true);
//echo ($accessToken['access_token']);
//die();
$data = array("First_Name"=>$first_name, "Last_Name"=>$last_name, "Email"=>$email, "Phone"=>$phone, "Description"=>($message), "Budget" => $budget, 'Subscribed_Newsletter' => $checkbox, "Lead_Date"=>$zoho_date, '$gclid'=>$zc_gad);
//$data = json_encode($data);
$encodedData = array();
$encodedData['data'][0] = $data;
//var_dump($data);
//echo(json_encode($encodedData));
//die();
//che
$url ="https://www.zohoapis.com/crm/v2/Leads";
$headers = array(
'Authorization: Zoho-oauthtoken '.$accessToken['access_token'],
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($encodedData));
$result = curl_exec($ch);
curl_close($ch);
//echo $result;
/**** End zoho CRM ****/
$success = true;
$msg = 'Done';
$leadSaving = print_r($result, true);
$leadSaving = $leadSaving . "\r\n" . $email;
$leadSaving = $leadSaving . "\r\n" . "request quote";
file_put_contents("lead-zoho-entry-status.txt", $leadSaving, FILE_APPEND);
file_put_contents("lead-zoho-entry-status.txt", "\r\n\r\n", FILE_APPEND); }
}
}
I tried and getting the following SUCCESS response
{"data":[{"code":"SUCCESS","details":{"Modified_Time":"2022-07-27T17:28:36+05:30","Modified_By":{"name":"Sourav Sinha","id":"1153488000000068001"},"Created_Time":"2022-07-27T17:28:36+05:30","id":"1153488000046560019","Created_By":{"name":"Sourav Sinha","id":"1153488000000068001"}},"message":"record added","status":"success"}]}
youremail#test.com
request quote
This is the code used in functions.php file
add_action('wpcf7_mail_sent','brainium_cf7_api_sender');
function brainium_cf7_api_sender($contact_form){
$title = $contact_form->title;
if( $title === 'Contact form 1') {
$submission = WPCF7_Submission::get_instance();
if( $submission ){
$posted_data = $submission->get_posted_data();
$first_name = $posted_data['first-name'];
$last_name = $posted_data['last-name'];
$email = $posted_data['your-email'];
$phone = $posted_data['Phone-no'];
$message = $posted_data['your-message'];
$budget = $posted_data['budget'];
$checkbox = $posted_data['checkbox-194'][0];
$auth = 'xxxxxxxxxxxx';
$refreshToken = "xxxxxxxxxxxx";
//get the last date and time of refresh token generation
//get the access token
$url = "https://accounts.zoho.com/oauth/v2/token";
$query = "refresh_token=xxxxxxxxxxxx&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxxxxx&grant_type=refresh_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$result = curl_exec($ch);
curl_close($ch);
//get the token from the JSON in result
$accessToken = json_decode($result, true);
//echo ($accessToken['access_token']);
//die();
$data = array("First_Name"=>$first_name, "Last_Name"=>$last_name, "Email"=>$email, "Phone"=>$phone, "Description"=>($message), "Budget" => $budget, 'Subscribed_Newsletter' => $checkbox, "Lead_Date"=>$zoho_date, '$gclid'=>$zc_gad);
//$data = json_encode($data);
$encodedData = array();
$encodedData['data'][0] = $data;
//var_dump($data);
//echo(json_encode($encodedData));
//die();
//che
$url ="https://www.zohoapis.com/crm/v2/Leads";
$headers = array(
'Authorization: Zoho-oauthtoken '.$accessToken['access_token'],
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($encodedData));
$result = curl_exec($ch);
curl_close($ch);
//echo $result;
// End zoho CRM
$success = true;
$msg = 'Done';
$leadSaving = print_r($result, true);
$leadSaving = $leadSaving . "\r\n" . $email;
$leadSaving = $leadSaving . "\r\n" . "request quote";
file_put_contents("lead-zoho-entry-status.txt", $leadSaving, FILE_APPEND);
file_put_contents("lead-zoho-entry-status.txt", "\r\n\r\n", FILE_APPEND);
}
}
}
<?php
$first_name = 'first-name';
$last_name = 'last-name';
$email = 'youremail#test.com';
$phone = '9876543210';
$message = 'your-message';
$budget = '1000';
$checkbox = '1';
$auth = 'fa738eaef1becee890f8935f65169e99';
$refreshToken = "1000.3c0d5bb96a00e9438d132d94a316a72b.2d5261b7e33c42614c08f1bd4e9a0f1a";
//get the last date and time of refresh token generation
//get the access token
$url = "https://accounts.zoho.com/oauth/v2/token";
$query = "refresh_token=xxxxxxxxxxxx&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxxxxx&grant_type=refresh_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$result = curl_exec($ch);
curl_close($ch);
//get the token from the JSON in result
$accessToken = json_decode($result, true);
//echo ($accessToken['access_token']);
//die();
$data = array("First_Name"=>$first_name, "Last_Name"=>$last_name, "Email"=>$email, "Phone"=>$phone, "Description"=>($message), "Budget" => $budget, 'Subscribed_Newsletter' => $checkbox, "Lead_Date"=>$zoho_date, '$gclid'=>$zc_gad);
//$data = json_encode($data);
$encodedData = array();
$encodedData['data'][0] = $data;
//var_dump($data);
//echo(json_encode($encodedData));
//die();
//che
$url ="https://www.zohoapis.com/crm/v2/Leads";
$headers = array(
'Authorization: Zoho-oauthtoken '.$accessToken['access_token'],
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($encodedData));
$result = curl_exec($ch);
curl_close($ch);
//echo $result;
/**** End zoho CRM ****/
$success = true;
$msg = 'Done';
$leadSaving = print_r($result, true);
$leadSaving = $leadSaving . "\r\n" . $email;
$leadSaving = $leadSaving . "\r\n" . "request quote";
file_put_contents("lead-zoho-entry-status.txt", $leadSaving, FILE_APPEND);
file_put_contents("lead-zoho-entry-status.txt", "\r\n\r\n", FILE_APPEND);

I am trying to get contact form 7 data to zoho crm ,it is working fine on local host but on live it is giving following error

It is working fine in localhost but when i updating it on live site it giving following error-
{"data":[{"code":"INVALID_DATA","details":{"maximum_length":20,"api_name":"Subscribed_Newsletter"},"message":"invalid data","status":"error"}]}
You can find the reference code below-
add_action('wpcf7_mail_sent','brainium_cf7_api_sender');
function brainium_cf7_api_sender($contact_form){
$title = $contact_form->title;
if( $title === 'Test') {
$submission = WPCF7_Submission::get_instance();
if( $submission ){
$posted_data = $submission->get_posted_data();
$first_name = $posted_data['first-name'];
$last_name = $posted_data['last-name'];
$email = $posted_data['your-email'];
$phone = $posted_data['Phone-no'];
$message = $posted_data['your-message'];
$budget = $posted_data['budget'];
$checkbox = $posted_data['checkbox-37'][0];
$auth = 'xxxxxxxxxxxx';
$refreshToken = "xxxxxxxxxxxx";
//get the last date and time of refresh token generation
//get the access token
$url = "https://accounts.zoho.com/oauth/v2/token";
$query = "refresh_token=xxxxxxxxxxxx&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxxxxx&grant_type=refresh_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$result = curl_exec($ch);
curl_close($ch);
//get the token from the JSON in result
$accessToken = json_decode($result, true);
//echo ($accessToken['access_token']);
//die();
$data = array("First_Name"=>$first_name, "Last_Name"=>$last_name, "Email"=>$email, "Phone"=>$phone, "Description"=>($message), "Budget" => $budget, 'Subscribed_Newsletter' => $checkbox, "Lead_Date"=>$zoho_date, '$gclid'=>$zc_gad);
//$data = json_encode($data);
$encodedData = array();
$encodedData['data'][0] = $data;
//var_dump($data);
//echo(json_encode($encodedData));
//die();
//che
$url ="https://www.zohoapis.com/crm/v2/Leads";
$headers = array(
'Authorization: Zoho-oauthtoken '.$accessToken['access_token'],
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($encodedData));
$result = curl_exec($ch);
curl_close($ch);
//echo $result;
// End zoho CRM
$success = true;
$msg = 'Done';
$leadSaving = print_r($result, true);
$leadSaving = $leadSaving . "\r\n" . $email;
$leadSaving = $leadSaving . "\r\n" . "request quote";
file_put_contents("lead-zoho-entry-status.txt", $leadSaving, FILE_APPEND);
file_put_contents("lead-zoho-entry-status.txt", "\r\n\r\n", FILE_APPEND);
}
}
}

How to remove product from collection using shopify api

https://wetion.myshopify.com/admin/collects/.jsonproduct_id=9706757444&collection_id=380751892';
I need to remove a product from the collection.is it possible?
$delete_exist_collect = array();
for($i=0 ; $i < $custom_collectionss ; $i++)
{
$delete_exist_collect = $product_data_collection['custom_collections'][$i]['id'];
$urli = $to_storeurl_shopify.'/admin/collects/.json?product_id='.$response->product->id.'&collection_id='.$delete_exist_collect;
echo $urli;
$newurl = str_replace(" ","",$urli);
$shopcurl = curl_init();
curl_setopt($shopcurl, CURLOPT_URL, $newurl);
curl_setopt($shopcurl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($shopcurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($shopcurl, CURLOPT_USERPWD,$to_shopify_u_p);
curl_setopt($shopcurl, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($shopcurl, CURLOPT_SSL_VERIFYPEER, false);
$responsee = curl_exec ($shopcurl);
curl_close ($shopcurl);
$product_data_collection = json_decode($responsee,TRUE);
}

I Make one code for create order in magento programmatically.

it's work fine but when i used Payment Method as "paypal_express" it redirect Error like : PayPal gateway has rejected request. Invalid token (#10410: Invalid token)
Give Proper Suggestion how to solve it.
My Code Like :
$ch = curl_init();
$clientId = "******";
$secret = "*******";
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
//curl_setopt($ch, CURLOPT_HTTPAUTH, true);
$result = curl_exec($ch);
if(empty($result))die("Error: No response.");
else
{
$json = json_decode($result);
$type = $json->token_type;
$token = $type." ".$json->access_token;
$proId = $this->getRequest()->getParam('payid');
//$proId1 = "PAY-6PY01870PN0146745KZTHFDY";
$proUrl = "https://api.sandbox.paypal.com/v1/payments/payment/".$proId;
$headers = array(
"Content-type: application/json",
"Authorization: ".$token,
);
curl_setopt($ch, CURLOPT_URL, $proUrl);
//curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$orderResult = curl_exec($ch);
$json = json_decode($orderResult);
$PayerID = $json->payer->payer_info->payer_id;
$PayerEmail = $json->payer->payer_info->email;
$PayerStatus = $json->payer->status;
$Merchant = $json->transactions[0]->related_resources[0]->sale->protection_eligibility;
$TransactionId = $json->transactions[0]->related_resources[0]->sale->id;
// echo $json->state."<br>";
// echo $json->payer->payment_method."<br>";
}
curl_close($ch);
/* End Access Token */
$userid = $this->getRequest()->getParam('userid');
$firstname = $this->getRequest()->getParam('firstname');
$lastname = $this->getRequest()->getParam('lastname');
$telephone = $this->getRequest()->getParam('telephone');
$street[0] = $this->getRequest()->getParam('street');
$city = $this->getRequest()->getParam('city');
$region_id = $this->getRequest()->getParam('region_id');
$region = $this->getRequest()->getParam('region');
$country_id = $this->getRequest()->getParam('country_id');
$postcode = $this->getRequest()->getParam('postcode');
$shippingmethod = $this->getRequest()->getParam('shippingmethod');
$shippingprice = $this->getRequest()->getParam('shippingprice');
$paymentmethod = $this->getRequest()->getParam('payment');
$email = $this->getRequest()->getParam('email');
$productId = $this->getRequest()->getParam('product_id');
$qty = $this->getRequest()->getParam('qty');
$websiteId = Mage::app()->getWebsite()->getId();
$optionValue = $this->getRequest()->getParam('optionvalue');
//echo "pro".$productId."--wty--".$qty."--op--".$optionValue;die();
$store = Mage::app()->getStore();
$customerAccountNo = $userid;
if($customerAccountNo)
{
// load customer object
$customerObj = Mage::getModel('customer/customer')->load($customerAccountNo);
// assign this customer to quote object, before any type of magento order, first create quote.
$quoteObj = Mage::getModel('sales/quote')->assignCustomer($customerObj);
$quoteObj = $quoteObj->setStoreId(Mage::app()->getStore()->getId());
// product id
$productId = 1781;
$productModel = Mage::getModel('catalog/product');
$productObj = $productModel->load($productId);
// for simple product
if ($productObj->getTypeId() == 'simple')
{
$quoteObj->addProduct($productObj , 1);
// for downloadable product
}
else if ($productObj->getTypeId() == 'downloadable')
{
$params = array();
$links = Mage::getModel('downloadable/product_type')->getLinks( $productObj );
$linkId = 0;
foreach ($links as $link) {
$linkId = $link->getId();
}
$params['product'] = $productId;
$params['qty'] = $qty;
$params['links'] = array($linkId);
$request = new Varien_Object();
$request->setData($params);
$quoteObj->addProduct($productObj , $request);
}
elseif ($productObj->getTypeId() == 'configurable')
{
$optionValue = $this->getRequest()->getParam('optionvalue');
$param = array(
'product' => $productId,
'super_attribute' => array(
184 => 50
),
'qty' => 2
);
$quoteObj->addProduct($productObj,new Varien_Object($param));
}
// sample billing address
$billingAddress = array
(
'email' => $email,
'firstname' => $firstname,
'lastname' => $lastname,
'telephone' => $telephone,
'street' => $street[0],
'country_id' => $country_id,
'city' => $city,
'postcode' => $postcode ,
'region_id' => $region_id,
'region' => $region,
'customer_address_id' => NULL,
);
$quoteBillingAddress = Mage::getModel('sales/quote_address');
$quoteBillingAddress->setData($billingAddress);
$quoteObj->setBillingAddress($quoteBillingAddress);
//if product is not virtual
if (!$quoteObj->getIsVirtual())
{
$shippingAddress = $billingAddress;
$quoteShippingAddress = Mage::getModel('sales/quote_address');
$quoteShippingAddress->setData($shippingAddress);
$quoteObj->setShippingAddress($quoteShippingAddress);
// fixed shipping method
$quoteObj->getShippingAddress()->setShippingMethod('ups_03');
$quoteObj->getShippingAddress()->setCollectShippingRates(true);
$quoteObj->getShippingAddress()->collectShippingRates();
$quoteObj->getShippingAddress()->setPaymentMethod('paypal_express');
}
$quoteObj->collectTotals();
$quoteObj->save();
$transaction = Mage::getModel('core/resource_transaction');
if ($quoteObj->getCustomerId())
{
$transaction->addObject($quoteObj->getCustomer());
}
$transaction->addObject($quoteObj);
$quoteObj->reserveOrderId();
$quotePaymentObj = $quoteObj->getPayment();
$quotePaymentObj->setMethod('paypal_express');
$quoteObj->setPayment($quotePaymentObj);
$convertQuoteObj = Mage::getSingleton('sales/convert_quote');
if ($quoteObj->getIsVirtual())
{
$orderObj = $convertQuoteObj->addressToOrder($quoteObj->getBillingAddress());
}
else
{
$orderObj = $convertQuoteObj->addressToOrder($quoteObj->getShippingAddress());
}
$orderPaymentObj = $convertQuoteObj->paymentToOrderPayment($quotePaymentObj);
$orderObj->setBillingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getBillingAddress()));
$orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($quoteObj->getPayment()));
if (!$quoteObj->getIsVirtual())
{
$orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getShippingAddress()));
}
// set payment options
$orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($quoteObj->getPayment()));
$items=$quoteObj->getAllItems();
foreach ($items as $item)
{
//#var $item Mage_Sales_Model_Quote_Item
$orderItem = $convertQuoteObj->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$orderObj->addItem($orderItem);
}
$orderObj->setCanShipPartiallyItem(false);
$totalDue = $orderObj->getTotalDue();
$transaction->addObject($orderObj);
$transaction->addCommitCallback(array($orderObj, 'place'));
$transaction->addCommitCallback(array($orderObj, 'save'));
try
{
$transaction->save();
} catch (Exception $e){
echo $e->getMessage();
//Mage::throwException('Order Cancelled Bad Response from Credit Authorization.');
}
$orderObj->sendNewOrderEmail();
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$orderObj, 'quote'=>$quoteObj));
$quoteObj->setIsActive(0);
$quoteObj->save();
}

Wordpress : Call wp_create_user function from external?

In Wordpress, i want to create New Users from external. I've found this is function in wordpress:
wp_create_user( $username, $password, $email );
So how can i run this function from external call please?
I mean, how to run this function from either:
Via simple URL with GET, like: www.example.com/adduser/?username=james&password=simpletext&email=myemail
Via cURL with POST
.. from external website.
You may try this but also make sure that the listening url has a handler to handle the request in your WordPress end (using GET methof)
function curlAdduser($strUrl)
{
if( empty($strUrl) )
{
return 'Error: invalid Url given';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $strUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$return = curl_exec($ch);
curl_close($ch);
return $return;
}
Call the function from external site :
curlAdduser("www.example.com/adduser?username=james&password=simpletext&email=myemail");
Update : using POST method
function curlAdduser($strUrl, $data) {
$fields = '';
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
$fields = rtrim($fields, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $strUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$return = curl_exec($ch);
curl_close($ch);
return $return;
}
Call the function with data
$data = array(
"username" => "james",
"password" => "simpletext",
"email" => "myemail"
);
curlAdduser("www.example.com/adduser", $data);

Resources