• Vishal Gaddi6
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 15
    Replies

Hi everyone

 

I need to send some data from salesforce to another webservice via XML....

 if anybody has any reference link or code, do let me knw...

 

 

 

 

Thanx in advance...

HI Everyone

 

I need to insert a new record in Remote Site Access via Visualforce page as User will only provide the domain name.....

Let me know if anyone can help......

 

 

 

Thanx in Advance

Vishal

 

Hi Everyone

 

Can we create custom fields using apex code ?? if anybody have any code sample or link then do let me know....

 

 

 

Thanx in advance

Vishal

Hi Everyone

 

Can we hit a local/private server using IP address with HTTP request in Salesforce ?? or the server should always be public....

 

 

Thanx in advance

Vishal.

Hi everyone...

 

I am passing 2 parameters from Salesforce to a php page using following code...

 

public class WebServiceCallout {

@future (callout=true)

public static void sendNotification(String name, String email) {

HttpRequest req = new HttpRequest();

HttpResponse res = new HttpResponse();

Http http = new Http();

req.setEndpoint('http://panelhouserepairs.com.au/EmployeeProfiles.php');

req.setMethod('POST');

system.debug('yesss' +name);

system.debug('yesss' +email);

req.setBody('name='+EncodingUtil.urlEncode(name, 'UTF-8')+'&email='+EncodingUtil.urlEncode(email, 'UTF-8'));req.setCompressed(true);

// otherwise we hit a limit of 32000

try {

system.debug('yesss' +name);

system.debug('yesss' +email);

res = http.send(req);

} catch(System.CalloutException e) {

System.debug('Callout error: '+ e);

System.debug(res.toString());

}

}

// run WebServiceCallout.testMe(); from Execute Anonymous to test

public static testMethod void testMe() {

WebServiceCallout.sendNotification('My Test Contactr','My Email');

}

}

 

Can i anyone let me know the code to read passed 2 parameters on the php page..... 

 

Thanx in Advance

Hi everyone

 

I need to push data from salesforce (on an event) to a website.... if anyone of you have done some work like this, juss let me know....

 

 

 

Thanx in advance

 

Hi everyone

 

I am having a website in a PHP based CMS and i wana link my website with Salefsorce via API..... i am juss worried about the API calls limit because it is a public website..... So if anyone of u hav worked on same project, then let me knw how to handle several login calls frm different or how to login juss once n evry user gets access.... 

 

 

 

Thanx in advance

Hey Everyone out there...

 

I am having following message while inserting a record into custom object via php script.

 

Strict Standards: Creating default object from empty value in C:\xampp\htdocs\Connection\soapclient\SforceBaseClient.php on line 520

 

Thanx in Advance...

Vishal

Hey Everyone !!!

 

Can we create Custom Object via PHP Script ??

 

Not Records, I want to create a new Custom Object into my Salesforce Database via PHp Script....  

Hey

 

I am using PHP to connect to Salesforce API and connection is established successfully. I have done the Insertion n Query part over Standard and Custom Objects.

 

I need some code to create a Custom Object in Salesforce via PHP Script.

If anyone can help,.....

Hi

 

I am trying to connect php page with my salesforce account. I have found the following code which is saved as SF_Connect.class.php 

 

 

<?php

 

class SF_Connect {   

private static $soapClient;

        private static $wsdlMethod;
        const SALESFORCE_USER = 'username';
        const SALESFORCE_PASS = 'passwrd';
        const SALESFORCE_TOKEN = 'XuQVD3uYJ8Q7w2jsIGdEGgl3W';
        const IN_DEBUG_MODE = true;
        const ERROR_EMAIL = 'vishal_gaddi@rediffmail.com';
        const SF_SOAPCLIENT_DIR = 'sf-lib/toolkit/soapclient/';


        public static function connect($wsdlMethod = 'partner') {       

 

        if (self::$soapClient) return;
       if ( !$wsdlMethod || !in_array($wsdlMethod, array('partner', 'enterprise', 'metadata')) ) {           die(((self::IN_DEBUG_MODE) ? 'Bad wsdl requested' : 'Unable to connect to salesforce.com'));       

}
       try {           

# Create client and connection           

self::$soapClient = self::getSoapClient($wsdlMethod);           

self::$soapClient->createConnection(self::SF_SOAPCLIENT_DIR . self::$wsdlMethod . '.wsdl.xml');
           

# Login           

$tmpLogin = self::$soapClient->login(self::SALESFORCE_USER,self::SALESFORCE_PASSself::SALESFORCE_TOKEN);


           # Ensure password is still valid           

if ( $tmpLogin->passwordExpired ) {

                if (self::IN_DEBUG_MODE) {                   

die('Password has expired');               

}               

return false;           

}           

return true;       

} catch ( SoapFault $e ) { 

         $errorMessage = "Error: [{$e->getCode()}] {$e->getMessage()}";           

$errorMessage .= '<br />';           

$errorMessage .= "File:{$e->getFile()}<br />Line: {$e->getLine()}";           

$errorMessage .= '<br />';           

$errorMessage .= '<pre>' . print_r($e->getTrace(), true) . '</pre>';
           

# While in debug we can display the error           

if ( self::IN_DEBUG_MODE ) {               

echo $errorMessage;           

} else {               

 

// To send HTML mail, the Content-type header must be set               

$headers = 'MIME-Version: 1.0' . "\r\n";               

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
               mail(self::ERROR_EMAIL, 'Salesforce Error!', $errorMessage, $headers);           

}           

return false;       

}   

}
        private static function getSoapClient($wsdlMethod) {

       switch (strtolower($wsdlMethod)) {

                

case 'enterprise': 

             

# Require Client               

require_once (self::SF_SOAPCLIENT_DIR . 'SforceEnterpriseClient.php'); 

             

# Set method

               self::$wsdlMethod = 'enterprise';   

 

           # Return object   

        return new SforceEnterpriseClient();   

                break; 

 

         case 'metadata':               

 

# Require Client               

require_once (self::SF_SOAPCLIENT_DIR . 'SforceMetadataClient.php');               

 

# Set method               

self::$wsdlMethod = 'metadata';               

 

# Return object
               return new SforceMetadataClient();               

break;           

 

case 'partner': 

 

                # Require Client               

require_once (self::SF_SOAPCLIENT_DIR . 'SforcePartnerClient.php');               

 

# Set method               

self::$wsdlMethod = 'partner';               

 

# Return object               

return new SforcePartnerClient();               

break;           

 

default:     

 

         die(((self::IN_DEBUG_MODE) ? 'Bad client requested' : 'Unable to connect to salesforce.com'));               break;       

}   

}
    /**     * Logout current connection     */

   

public static function logout() { 

     self::$soapClient->logout();   

}

 

   /**     * Return soap client     */   

 

public static function getClient() {       

return self::$soapClient;   

}

}
ini_set("soap.wsdl_cache_enabled", "0");
?>

 

 

Next i have saved another page as show.php with following code:

 

<?php

 

# Require the connection class

require_once 'sf-lib/SF_Connect.class.php';

# Initialize the connection

if ( !SF_Connect::connect() ) {   

# Connection failed, output error   

die('Unable to connect to salesforce.com');

}

/** * Successful connection * * Process actions here */
# Demo

$query = "SELECT Id, FirstName, LastName from Lead";$queryResult = SF_Connect::getClient()->query($query);$records = $queryResult->records;

foreach ($records as $sObject) {   

echo "Id = ".$sObject->Id; 

echo '<br />';

echo "First Name = ".$sObject->fields->FirstName;

echo '<br />';

       echo "Last Name = ".$sObject->fields->LastName; 

       echo '<hr />';

}

 

# Don't forget to logout

SF_Connect::logout();  
?>

 

 

But above page i.e. show.php is giving error of " Unknown method "Login";

 

Can someone write me a simple code to connect to my salesforce account and fetching custom object records....

HI Everyone

 

I need to insert a new record in Remote Site Access via Visualforce page as User will only provide the domain name.....

Let me know if anyone can help......

 

 

 

Thanx in Advance

Vishal

 

Hi everyone

 

I need to push data from salesforce (on an event) to a website.... if anyone of you have done some work like this, juss let me know....

 

 

 

Thanx in advance

 

Hi there,

 

I need some help in figuring out where the issue is in this salesforce connection script, here is what I've got and done so far:

 

1.  I installed PHP Toolkit 20.0

2.  Downloaded enterprise wsdl and updated the file in toolkit under soapclient directory

3.  Updated security token to make sure it was accurate for the account I'll be creating a connection to

4.  Checked phpinfo() on my server to make sure all requirements were met (PHP Version 5.2.13, openssl enabled, SOAP Client and Server both enabled)

5.  Got the log in script uploaded to the server and ran it for the first time

6.  Fixed errors that I initially got related to paths and syntax

7.  Currently, the script works to $client = new SforceEnterpriseClient();, but the next line ($client->createConnection($wsdl);) is not executed properly, I think and although I've added error reporting in the script, I'm not getting any message other than the 500 internal server error as you'll see in point #9 and ultimately, I can't even confirm that I've actually connected to SF because the script is not getting that far

8.  I put in an echo statement right after $client = new SforceEnterpriseClient(); to make sure it was getting to that point, and that worked, because the screen output the message when the script was run;  I did the same after $client->createConnection($wsdl);, but the screen did not show the echoed message when the script was run

9.  If I do not have the echo statement after $client = new SforceEnterpriseClient();, I get a 500 internal server error on the screen when the script is run

 

The following is the log in script:

 

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once ('lib/soapclient/SforceEnterpriseClient.php');
require_once ('lib/soapclient/SforceHeaderOptions.php');

// Login to salesforce.com
$login = 'my email for log in';
$password = 'my current pw that is confirmed correct';
$key = 'my updated token';

//join Password and Key here
$password = $password . $key;

$wsdl = 'lib/soapclient/enterprise.wsdl.xml';
$client = new SforceEnterpriseClient();
$client->createConnection($wsdl);

try
{
    $loginResult = $client->login($login, $password);

    if ($loginResult->passwordExpired)
    {
        unset($client);
    }
}
catch (exception $e)
{
    $error = '<pre>' . print_r($e, true) . '</pre>';
    mail('my email again', 'Salesforce Login Error', $error);
    unset($client);
}
?> 

 

 

I've exhausted any ideas for this issue, so I'm reaching out to anyone who might be able to help.  Thank you.

I am trying to insert a custom object into another custom object which is its master. I cannot get salesforce's php toolkit to insert into any object. I can query the master custom object along with querying the child custom object. I am using salesforce enterprise, below is my code in which I am trying to do the insert.

 

Can someone, any one can help me. Thanks in advance.

 

 

$sObject = new stdClass();
$sObject->CurrencyIsoCode = 'USD';
$sObject->Downloader__c = 'PHP Test';
$sObject->Package__c = 'Test PHP';
$sObject->Product_Trial__c = 'XXXXXXXXXXXXXXX';

$upsertResponse = $this->_mySforceConnection->upsert('NSP_Trial_Download__c', array($sObject),$objectType);
echo "Upserting New NSP_Trial_Download__c\(existing)r\n";
print_r($upsertResponse);

catch (Exception $e) {
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;

}

 

  • November 02, 2011
  • Like
  • 0

Hey Everyone !!!

 

Can we create Custom Object via PHP Script ??

 

Not Records, I want to create a new Custom Object into my Salesforce Database via PHp Script....  

Hey

 

I am using PHP to connect to Salesforce API and connection is established successfully. I have done the Insertion n Query part over Standard and Custom Objects.

 

I need some code to create a Custom Object in Salesforce via PHP Script.

If anyone can help,.....

Hi

 

I am trying to connect php page with my salesforce account. I have found the following code which is saved as SF_Connect.class.php 

 

 

<?php

 

class SF_Connect {   

private static $soapClient;

        private static $wsdlMethod;
        const SALESFORCE_USER = 'username';
        const SALESFORCE_PASS = 'passwrd';
        const SALESFORCE_TOKEN = 'XuQVD3uYJ8Q7w2jsIGdEGgl3W';
        const IN_DEBUG_MODE = true;
        const ERROR_EMAIL = 'vishal_gaddi@rediffmail.com';
        const SF_SOAPCLIENT_DIR = 'sf-lib/toolkit/soapclient/';


        public static function connect($wsdlMethod = 'partner') {       

 

        if (self::$soapClient) return;
       if ( !$wsdlMethod || !in_array($wsdlMethod, array('partner', 'enterprise', 'metadata')) ) {           die(((self::IN_DEBUG_MODE) ? 'Bad wsdl requested' : 'Unable to connect to salesforce.com'));       

}
       try {           

# Create client and connection           

self::$soapClient = self::getSoapClient($wsdlMethod);           

self::$soapClient->createConnection(self::SF_SOAPCLIENT_DIR . self::$wsdlMethod . '.wsdl.xml');
           

# Login           

$tmpLogin = self::$soapClient->login(self::SALESFORCE_USER,self::SALESFORCE_PASSself::SALESFORCE_TOKEN);


           # Ensure password is still valid           

if ( $tmpLogin->passwordExpired ) {

                if (self::IN_DEBUG_MODE) {                   

die('Password has expired');               

}               

return false;           

}           

return true;       

} catch ( SoapFault $e ) { 

         $errorMessage = "Error: [{$e->getCode()}] {$e->getMessage()}";           

$errorMessage .= '<br />';           

$errorMessage .= "File:{$e->getFile()}<br />Line: {$e->getLine()}";           

$errorMessage .= '<br />';           

$errorMessage .= '<pre>' . print_r($e->getTrace(), true) . '</pre>';
           

# While in debug we can display the error           

if ( self::IN_DEBUG_MODE ) {               

echo $errorMessage;           

} else {               

 

// To send HTML mail, the Content-type header must be set               

$headers = 'MIME-Version: 1.0' . "\r\n";               

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
               mail(self::ERROR_EMAIL, 'Salesforce Error!', $errorMessage, $headers);           

}           

return false;       

}   

}
        private static function getSoapClient($wsdlMethod) {

       switch (strtolower($wsdlMethod)) {

                

case 'enterprise': 

             

# Require Client               

require_once (self::SF_SOAPCLIENT_DIR . 'SforceEnterpriseClient.php'); 

             

# Set method

               self::$wsdlMethod = 'enterprise';   

 

           # Return object   

        return new SforceEnterpriseClient();   

                break; 

 

         case 'metadata':               

 

# Require Client               

require_once (self::SF_SOAPCLIENT_DIR . 'SforceMetadataClient.php');               

 

# Set method               

self::$wsdlMethod = 'metadata';               

 

# Return object
               return new SforceMetadataClient();               

break;           

 

case 'partner': 

 

                # Require Client               

require_once (self::SF_SOAPCLIENT_DIR . 'SforcePartnerClient.php');               

 

# Set method               

self::$wsdlMethod = 'partner';               

 

# Return object               

return new SforcePartnerClient();               

break;           

 

default:     

 

         die(((self::IN_DEBUG_MODE) ? 'Bad client requested' : 'Unable to connect to salesforce.com'));               break;       

}   

}
    /**     * Logout current connection     */

   

public static function logout() { 

     self::$soapClient->logout();   

}

 

   /**     * Return soap client     */   

 

public static function getClient() {       

return self::$soapClient;   

}

}
ini_set("soap.wsdl_cache_enabled", "0");
?>

 

 

Next i have saved another page as show.php with following code:

 

<?php

 

# Require the connection class

require_once 'sf-lib/SF_Connect.class.php';

# Initialize the connection

if ( !SF_Connect::connect() ) {   

# Connection failed, output error   

die('Unable to connect to salesforce.com');

}

/** * Successful connection * * Process actions here */
# Demo

$query = "SELECT Id, FirstName, LastName from Lead";$queryResult = SF_Connect::getClient()->query($query);$records = $queryResult->records;

foreach ($records as $sObject) {   

echo "Id = ".$sObject->Id; 

echo '<br />';

echo "First Name = ".$sObject->fields->FirstName;

echo '<br />';

       echo "Last Name = ".$sObject->fields->LastName; 

       echo '<hr />';

}

 

# Don't forget to logout

SF_Connect::logout();  
?>

 

 

But above page i.e. show.php is giving error of " Unknown method "Login";

 

Can someone write me a simple code to connect to my salesforce account and fetching custom object records....

Hi,

 

I am using oauth2 to connect to the php toolkit. I have managed to log in and use all the api's functions except logout(). How can I log out of a session that I am currently in? whenver i use the $mySforceConnection->logout(); This is the error that I get when I run this function:

Fatal error: Uncaught SoapFault exception: [soapenv:Server] No such operation 'logout' in /home/ygdporta/public_html/demo2/soapclient/SforceBaseClient.php:174 Stack trace: #0 /home/ygdporta/public_html/demo2/soapclient/SforceBaseClient.php(174): SoapClient->__call('logout', Array) #1 /home/ygdporta/public_html/demo2/soapclient/SforceBaseClient.php(174): SoapClient->logout() #2 /home/ygdporta/public_html/demo2/index.php(21): SforceBaseClient->logout() #3 {main} thrown in /home/ygdporta/public_html/demo2/soapclient/SforceBaseClient.php on line 174

 Is there another way to end my session?

  • September 12, 2011
  • Like
  • 0