dtslobe4694 2010-10-22 21:25
浏览 37
已采纳

如何发布到表单并填充选择倍数?

I'm doing something a bit strange here, I'm querying data out of my local database and posintg it to Salesforce form using cURL. The data posts correctly to Salesforce. However, the select multiple is not getting the correct values selected. See $sd["location"] below in my code:

    //init curl
    $ch = curl_init();

    //setup the params
    $url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
    $oid = "HIDDEN";

    //setup the superdelegate array
    $sd = array();
    $sd["oid"] = $oid;
    $sd["retURL"] = "";  
    $sd["first_name"] = "1144asdfsadf4"; 
    $sd["last_name"] = "SDFSD1111";
    $sd["state"] = "IL";
    $sd["location"] = '"Chicago","New York","California"'; //this is the value that submits to the select multiple

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($sd));

    //post to Salesforce and then close the connection 
    curl_exec($ch); 
    curl_close($ch);

The select multiple is already setup in Salesforce with a 30 different locations. I'm trying to pass the cities that should be selected (Chicago, New York, California). Can you help me fix my code to get this to work correctly?

  • 写回答

5条回答 默认 最新

  • dongshen7561 2010-10-26 21:33
    关注

    I figured it out. This ended up doing it:

    Sending as "value1;value2" doesn't work. i.e. implode(";", $array) or join() doesn't work.

    Had to split the values like this in the POST string, oddly:

    $post_string .= "&the_field=value1 $the_field=value2 $the_field=value3";

    Now works fine.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计