json - Salesforce callout using PHP -


apologies, since may not know terminologies salesforce api. started programming connector interact salesforce , stuck.

i have requirement, each time new entry added leads section, have retrieve couple of fields (firstname , product code) , pass different software makes use of php.

<?php     require "conf/config_cleverbridge_connector.inc.php";  require "include/lc_connector.inc.php";   // start of main program  // read basic parameters if ($lc_username === "") {     $lc_username  = readparam("user"); } if ($lc_password === "") {     $lc_password  = readparam("password"); } $orderid      = ""; $customerid   = substr(readparam("purchase_id"), 0, 10); $comment      = readparam("email")."-".readparam("purchase_id");  // create product array $products = array();  $itemid     = readparam("internal_product_id");  $quantity   = 1; if (!once_per_purchased_quantity) {     $quantity = readparam("quantity"); }  // add product product array $products[] = array (     "itemidentification" => $itemid,     "quantity"           => $quantity, );  // create order $order = array(     "orderidentification"    => $orderid,     "customeridentification" => $customerid,     "comment"                => $comment,     "product"                => $products, );  // calling webservice $ticket = doorder($lc_username, $lc_password, $order); if ($ticket) {     header("http/1.1 200 ok");     header("content-type: text/plain");     print ticket_url.$result->order->ticketidentification;     exit; } else {     $error = "no result wsconnector_doorder";     trigger_error($error, e_user_warning);     printerror(500, "internal error.");     exit; }  // end of main program  ?> 

now code got , have work with. , hosted on different remote server. very new salesforce , not sure how trigger calling php file on remote site.

the basic idea is: 1. new entry in lead created. 2. 2 fields (custid , prodid) sent php file have pasted above (some of variables different) 3. processing , sends 2 fields salesforce.

any or guidance appreciated. links read on okay clueless.

ps: have example makes use of json messages if may make difference. thanks

i'll repost links comment :)


if php endpoint visible on open web (not part of intranet or own localhost) simplest thing send outbound message salesforce. no coding required, xml document you'll have parse on php side. plus automatically attempt resend messages if host unreachable...

if app can't accessed sf servers think php app have "actor". querying sf every x minutes new leads or maybe subscribing streaming api... mean you'd have store credentials sf on php app , remember either change password periodically or set on "integration user"'s profile "password never expires" checkbox.

so you're getting notification, generate tickets, time send them back. want pretend update of lead done person created or want see "last modified by: integration user"? outbound message can contain session id can use act person initiated action (created lead , fired workflow) - @ least until log out or session timeouts.

for message can use soap or rest salesforce apis - read docs figure out how send update command (and if want make clear done special user associated php app - how log in apis). think user's profile must have "api enabled" ticked before reuse somebody's session maybe it's better have dedicated account integrations that...

another thing keep in mind if it'd outbound messages ignore messages sent sandboxes if makes test environment not call "production" database of tickets. can remember modify outbound message , remote site setting every time sandbox made you'll have "prod talking prod, test talking test". know can include user's session id in om - maybe can add organization's id (for production it'll stay same, every new sandbox have new id).


the problem approach might not scale. if 1000 leads inserted in 1 batch (for example data loader) - you'll spammed 1000 outbound messages. server must able handle such load... mean you're using 1 api request send every single update back. can check limit of api requests in setup -> company information. developer edition have limit low, sandboxes better, production best (it depends how many user licenses have bought). that's why i've asked batching them up.

more coding more reliable ask sf changes every x minutes (streaming api? normal query? check "web hook" answer) , send update of these records in 1 go. select id, name lead ticket__c = null (note there's nothing and lastmodifieddate >= :lasttimeichecked)...


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -