I'm getting this error " Ooop! Error: Element {}item invalid at this location " at the time of calling Salesforce web service in PHP.
Bellow are my approaches:
require_once('salesforceAPI/soapclient/SforceEnterpriseClient.php');
require_once('salesforceAPI/soapclient/SforceHeaderOptions.php');
$sfdc = new SforceEnterpriseClient();
$SoapClient = $sfdc->createConnection('enterprise.wsdl.xml');
$loginResult = false;
$loginResult = $sfdc->login(USER, PASSWORD . SECURITY_KEY);
$parsedURL = parse_url($sfdc->getLocation());
define("_SFDC_SERVER_", substr($parsedURL['host'], 0, strpos($parsedURL['host'], '.')));
define("_WS_NAME_", 'salesforceAPI/Ctest');
define("_WS_WSDL_", _WS_NAME_ . '.xml');
define("_WS_ENDPOINT_", 'https://' . _SFDC_SERVER_ . '.salesforce.com/services/wsdl/class/' . _WS_NAME_);
define("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/' . _WS_NAME_);
$client = new SoapClient(_WS_WSDL_);
$sforce_header = new SoapHeader(_WS_NAMESPACE_, "SessionHeader", array("sessionId" => $sfdc->getSessionId()));
$client->__setSoapHeaders(array($sforce_header));
$method = $client->__getFunctions();
$wsParams = array('accName' => 'dasarathi');
$client->cInsert($wsParams);
I have no clue for solution.
It was a file path issue. Below is the rectification:
define("_WS_NAME_", 'salesforceAPI/Ctest');
// there is no such path http://soap.sforce.com/schemas/class/slesforceAPI/Ctest
define("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/' . _WS_NAME_);
I just redeclared the WS_NAME constant:
define("_WS_NAME_", 'Ctest');
Related
I'm using the qbo-api-v3 for PHP to authenticate and retrieve a Balance Sheet report via PHP script. This has been working just fine over the last 6 months, but recently stopped returning data (returns NULL for repsonseCOde, responseBody, and responsArray). I can't figure out why - any ideas? Thanks!
// qbo API
require_once dirname(__FILE__).'/../v3-php-sdk-2.2.0-RC/config.php';
require_once(PATH_SDK_ROOT . 'Core/ServiceContext.php');
require_once(PATH_SDK_ROOT . 'PlatformService/PlatformService.php');
require_once(PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php');
require_once(PATH_SDK_ROOT . 'Core/CoreHelper.php');
require_once(PATH_SDK_ROOT . 'DataService/Batch.php');
require_once(PATH_SDK_ROOT . 'DataService/IntuitCDCResponse.php');
require_once(PATH_SDK_ROOT . 'Data/IntuitRestServiceDef/IPPAttachableResponse.php');
require_once(PATH_SDK_ROOT . 'Data/IntuitRestServiceDef/IPPFault.php');
require_once(PATH_SDK_ROOT . 'Data/IntuitRestServiceDef/IPPError.php');
require_once('RestServiceHandler.php');
require_once(PATH_SDK_ROOT . 'Core/OperationControlList.php');
// QBO Service Context
$serviceType = IntuitServicesType::QBO;
$oauth['AccessToken'] = ...
$oauth['AccessTokenSecret'] = ...
$oauth['ConsumerKey'] = ...
$oauth['ConsumerSecret'] = ...
$oauth['RealmID'] = ...
$requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'),
ConfigurationManager::AppSettings('AccessTokenSecret'),
ConfigurationManager::AppSettings('ConsumerKey'),
ConfigurationManager::AppSettings('ConsumerSecret'));
$serviceContext = new ServiceContext($oauth['RealmID'], $serviceType, $requestValidator); //d($serviceContext);
if (!$serviceContext) exit("Problem while initializing ServiceContext.\n");
// query for Balance Sheet Report - https://developer.intuit.com/docs/api/accounting/balance%20sheet
$report = 'BalanceSheet';
$query = "start_date=$start_date&end_date=$end_date";
$uri = "company/{1}/reports/$report?{2}";
$uri = str_replace("{1}", $oauth['RealmID'] , $uri);
$uri = str_replace("{2}", $query , $uri);
// Creates request parameters
$requestParameters = new RequestParameters($uri,'GET',CoreConstants::CONTENTTYPE_APPLICATIONJSON, NULL);
$restRequestHandler = new RestServiceHandler($serviceContext);
// Make the request
list($responseCode,$responseBody) = $restRequestHandler->GetReportsResponse($requestParameters, NULL, NULL);
$responseArray = json_decode($responseBody, true);
Can anybody help me to rewrite the following request in curl or anything similar which is available in php 5.6? I'm new with http request in PHP and I'm not able to use the HttpRequest class cause it can't be found on the server. Other suggestions are welcome too. Maybe there is already a library?
$path = "content/images/calendarmotiv/";
$fail = true;
$tmp = $_FILES['imagetarget']['tmp_name'];
$name = basename($_FILES['imagetarget']['name']);
if(move_uploaded_file($tmp, $path.$name))
{
// http request body
$now = new DateTime('NOW');
$body = json_encode(array(
"name" => $name,
"width" => 1024.0,
"image_url" => base64_encode($path.$name),
"active_flag" => 1,
"application_metadata_url" => base64_encode($_POST["metadata"]))
);
$http_verb = "POST";
$content_md5 = md5($body);
$content_type = "application/json";
$date = str_replace("+0000", "GMT", $now->format(DateTime::RFC1123));
$request_path = "<a href='https://vws.vuforia.com/targets'> https://vws.vuforia.com/targets</a>";
// auth string for header
$string_to_sign = $http_verb . "\n" . $content_md5 . "\n" . $content_type . "\n" . $date . "\n" . $request_path;
$secret_key = "mykey";
$signature = hash_hmac("sha1", $string_to_sign, $secret_key);
$authstring = "VWS " . $secret_key . ":" . $signature;
// the request
$request = new HttpRequest($request_path, HttpRequest::METH_POST);
$request->setContentType($content_type);
$request->setBody($body);
$request->addHeaders(array(
"Date" => $date,
"Authorization" => $authstring));
$request->send();
echo $request->getRequestMessage();
echo $request->getResponseMessage();
}
I've created a Vuforia client class in PHP for basic operations with Vuforia target database:
https://github.com/FionNoir/VuforiaClient
I want to update User table of DATA BROWSER using objectId(With out getting user to log in ) using following code.
But I am getting:
error({"code":101,"error":"object not found for update"})
can any one tell me what is wrong with this:
$className = "Classname";
$objectIdToEdit = $_SESSION['objectId'];
$url = 'https://api.parse.com/1/classes/' . $className . '/' . $objectIdToEdit;
$appId = '***********************';
$restKey = '***********';
$updatedData = '{"firstname":"Billie123"}';
$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_PORT,443);
curl_setopt($rest,CURLOPT_CUSTOMREQUEST,"PUT");
curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);
curl_setopt($rest,CURLOPT_POSTFIELDS,$updatedData);
curl_setopt($rest,CURLOPT_HTTPHEADER, array(
"X-Parse-Application-Id: " . $appId,
"X-Parse-Master-Key: " . $restKey,
"Content-Type: application/json")
);
$response = curl_exec($rest);
echo $response;
I solved problem my self ,URL I was using is to save data
$url = 'https://api.parse.com/1/classes/' . $className . '/' . $objectIdToEdit;
I just changed URL to update data and problem is solved
$url = 'https://api.parse.com/1/' . $className . '/' . $objectIdToEdit;
thanks Ghost for editing
I am new in EAN development. I am developing hotel booking system in PHP using EAN. I want to fetch the reservation details from EAN API.
Following is my code:
$itinerary = xxxxxx;
$cid = 55505;
$minorRev = 13;
$apiKey = "y2dfnyvwbwkvgth76hfjdej7";
$locale = "en_US";
$currencyCode = "USD";
$customerSessionId;
$customerUserAgent;
$customerIpAddress;
$url = "http:api.ean.com/ean-services/rs/hotel/v3/";
$urlBook = "https:book.api.ean.com/ean-services/rs/hotel/v3/";
$url = ($service == 'res') ? $urlBook : $url;
$url .= $service
. "?minorRev={$minorRev}"
. "&cid={$cid}"
. "&apiKey={$apiKey}"
. "&customerUserAgent=" . rawurlencode($customerUserAgent)
. "&customerIpAddress={$customerIpAddress}"
. "&customerSessionId={$customerSessionID}"
. "&locale={$locale}"
. "¤cyCode={$currencyCode}";
$xml = "
<HotelItineraryRequest>
<itineraryId>{$itinerary}</itineraryId>
<email>customer#mail.com</email>
</HotelItineraryRequest>
";
$curl = new Curl();
$info = $curl->exec($xml, $url, "ItinerarySearch");
print_r($info);
It showing the following error :
Cannot service this request.Authentication failure
What is the problem with this code. Is there any solution that how can I get Reservation details from EAN.
I use the demo php code library from expedia : http://developer.ean.com/code_library/samples/PHP_Booking
Thanks in advance.
I am able to get access_token for multiple permissions like emails, contacts, docs, etc. using oAuth 2.0. I have access_token
I got contacts using the following code.
$url = 'https://www.google.com/m8/feeds/contacts/default/full?max- results='.$max_results.'&oauth_token='.$access_token;
$response_contacts= curl_get_file_contents($url);
Now i want to get users Emails using this access_token.
i used this url . but it gives 401 unauthorized Error
$url = 'https://mail.google.com/mail/feed/atom&oauth_token='.$access_token;
$response_emails= curl_get_file_contents($url);
please guide me how can i get emails using access_token.
I've seen references to the Gmail feed using oauth_token as a request parameter. However, once I used the OAuth Playground I discovered that you need to pass your OAuth information as an Authorization header, as you'll see below.
<?php
$now = time();
$consumer = ...; // your own value here
$secret = ...; // your own value here
$nonce = ...; // same value you've been using
$algo = "sha1";
$sigmeth = "HMAC-SHA1";
$av = "1.0";
$scope = "https://mail.google.com/mail/feed/atom";
$path = $scope;
$auth = ...; // an object containing outputs of OAuthGetAccessToken
$args = "oauth_consumer_key=" . urlencode($consumer) .
"&oauth_nonce=" . urlencode($nonce) .
"&oauth_signature_method=" . urlencode($sigmeth) .
"&oauth_timestamp=" . urlencode($now) .
"&oauth_token=" . urlencode($auth->oauth_token) .
"&oauth_version=" . urlencode($av);
$base = "GET&" . urlencode($path) . "&" . urlencode($args);
$sig = base64_encode(hash_hmac($algo, $base,
"{$secret}&{$auth->oauth_token_secret}", true));
$url = $path . "?oauth_signature=" . urlencode($sig) . "&" . $args;
// Create a stream
$opts = array(
"http" => array(
"method" => "GET",
"header" => "Authorization: OAuth " .
"oauth_version=\"{$av}\", " .
"oauth_nonce=\"{$nonce}\", " .
"oauth_timestamp=\"{$now}\", " .
"oauth_consumer_key=\"{$consumer}\", " .
"oauth_token=\"{$auth->oauth_token}\", " .
"oauth_signature_method=\"{$sigmeth}\", " .
"oauth_signature=\"{$sig}\"\r\n"
)
);
$context = stream_context_create($opts);
$out = file_get_contents($path, false, $context);
?>