how to connect with salesforce using php? - php

I am trying to connect with Salesforce using below lib and getting below issue and unable to find how
to enable the API as per Error.
https://github.com/developerforce/Force.com-Toolkit-for-PHP
Code:-
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once ('soapclient/SforcePartnerClient.php');
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection("soapclient/partner.wsdl.xml");
$mylogin = $mySforceConnection->login("xyz#gmail.com", "pass#xa9Ur9xMD6qqdRhdmLBuiRev");
var_dump($mylogin);die;
?>
Fatal error: Uncaught SoapFault exception: [sf:API_DISABLED_FOR_ORG] API_DISABLED_FOR_ORG:
API is not enabled for this Organization or Partner in
/var/www/mssdev/force/soapclient/SforceBaseClient.php:168 Stack trace:
#0 /var/www/mssdev/force/soapclient/SforceBaseClient.php(168): SoapClient->__call('login', Array)
#1 /var/www/mssdev/force/soapclient/SforceBaseClient.php(168): SforceSoapClient->login(Array)
#2 /var/www/mssdev/force/index.php(11): SforceBaseClient->login('xyz#gm...', 'fas#xa9Ur9...')
#3 {main} thrown in /var/www/mssdev/force/soapclient/SforceBaseClient.php on line 168

You are probably using Salesforce Gorup or Professional edition where the API is not available.
Other scenario (if You have other edition tham mentioned above) that the API is not enabled for Your user. However from the error message the most possible is scenario #1.

Use the developer account and the issue has solved.

Related

Twilio Uncaught Twilio\Exceptions\RestException: [HTTP 401] Unable to fetch record:

Am trying to Fetch a Queue resource on twilio i want to get the current_size (queue size)
am using PHP code below
use Twilio\Rest\Client;
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$twilio = new Client($sid, $token);
$queue = $twilio->queues("QUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
->fetch();
print($queue->friendlyName);
but i keep getting this error
Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 401] Unable to fetch record: Authentication Error - invalid username in C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Version.php:86 Stack trace: #0 C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Version.php(111): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to fetch...') #1 C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Rest\Api\V2010\Account\QueueContext.php(51): Twilio\Version->fetch('GET', '/Accounts/AP726...') #2 C:\xampp\htdocs\calls\agent\incoming.php(22): Twilio\Rest\Api\V2010\Account\QueueContext->fetch() #3 {main} thrown in C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Version.php on line 86
any solution how to fix this? and or get the current queue size
Please help.
Thanks in advance
Are you able to successfully execute a curl query from the Twilio API explorer, or from your machine to fetch the same information?
https://www.twilio.com/console/api-explorer/voice/queues/read
This error seems to be caused by passing an invalid SID.

Unauthorized: 401 Azure Media Service in PHP. How do I connect to Azure Media Service through PHP

I am trying to connect to Azure Media Service through PHP SDK provided by Azure on github. The userconfig.php has few params, I gave all my credentials but I'm getting
"Fatal error: Uncaught WindowsAzure\Common\ServiceException: Fail:
Code: 401"
<?php
set_time_limit(600); //set timeout to 10 minutes, or you can set max_execution_time in php.ini
date_default_timezone_set('America/Los_Angeles');
$tenant = "******.onmicrosoft.com";
$username = '***#*****.com';
$password = '****#12345';
$clientId = "*******-*******-46e9-b525-5f1f2ec4e4ea";
$clientKey = "*******-*******/uUS+hKm67kfwZZs4w4=";
$restApiEndpoint = "https://indwaretest1.restv2.japanwest.media.azure.net/api/";
// $pfxFileName = "C:\\Path\\To\\keystore.pfx";
// $pfxPassword = "KeyStorePassword";
I'm getting this error..
$ php index.php
PHP Fatal error: Uncaught WindowsAzure\Common\ServiceException: Fail:
Code: 401
Value: Unauthorized
details (if any): . in D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\Http\HttpClient.php:405
Stack trace:
#0 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\Http\HttpClient.php(301): WindowsAzure\Common\Internal\Http\HttpClient::throwIfError(401, 'Unauthorized', Object(GuzzleHttp\Psr7\Stream), Array)
#1 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\RestProxy.php(144): WindowsAzure\Common\Internal\Http\HttpClient->sendAndGetHttpResponse(Array, Object(WindowsAzure\Common\Internal\Http\Url))
#2 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\ServiceRestProxy.php(89): WindowsAzure\Common\Internal\RestProxy->sendHttpContext(Object(WindowsAzure\Common\Internal\Http\HttpCallContext))
#3 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\ServiceRestProxy.php(128): WindowsAzure\Common\Internal\ServiceRestProxy->sendHttpContext(Object(WindowsAzure\Common\Internal in D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\Http\HttpClient.php on line 405
Fatal error: Uncaught WindowsAzure\Common\ServiceException: Fail:
Code: 401
Value: Unauthorized
details (if any): . in D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\Http\HttpClient.php:405
Stack trace:
#0 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\Http\HttpClient.php(301): WindowsAzure\Common\Internal\Http\HttpClient::throwIfError(401, 'Unauthorized', Object(GuzzleHttp\Psr7\Stream), Array)
#1 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\RestProxy.php(144): WindowsAzure\Common\Internal\Http\HttpClient->sendAndGetHttpResponse(Array, Object(WindowsAzure\Common\Internal\Http\Url))
#2 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\ServiceRestProxy.php(89): WindowsAzure\Common\Internal\RestProxy->sendHttpContext(Object(WindowsAzure\Common\Internal\Http\HttpCallContext))
#3 D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\ServiceRestProxy.php(128): WindowsAzure\Common\Internal\ServiceRestProxy->sendHttpContext(Object(WindowsAzure\Common\Internal in D:\PHP\azure\vendor\microsoft\windowsazure\src\Common\Internal\Http\HttpClient.php on line 405
According to the error message, I suppose you have not given a role to your service principal for the media service.
To fix the issue, navigate to the media service in the portal -> Access control (IAM) -> Add role assignment -> select your service principal(just search the clientId ) and give the Contributor or Owner role -> Save, then it should work.
For more details, refer to this link.

OpenTok PHP SDK createSession not working

I've just installed the latest php sdk of opentok.
I cannot get a session to be created and it's extremely frustrating.
I know the SDK is correctly imported because my first call works. Here is my code.
<?PHP
require("./../classes/opentok.phar");
use OpenTok\OpenTok;
use OpenTok\Session;
use OpenTok\Role;
use OpenTok\MediaMode;
$API_KEY = '45972332';
$API_SECRET = 'HIDDEN_FOR_MY_PROTECTION';
$apiObj = new OpenTok($API_KEY, $API_SECRET);
var_dump($apiObj); // this returned successful data.
$session = $apiObj->createSession(array('mediaMode' =>
MediaMode::RELAYED)); // this errors out the script.
?>
This is the error it returns to me.
Fatal error: Uncaught exception 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client error response [status code] 403 [reason phrase] Forbidden [url] https://api.opentok.com/session/create' in phar:///var/www/html/API/classes/opentok.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43
Stack trace:
#0 phar:///var/www/html/API/classes/opentok.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(145): Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response))
#1 [internal function]: Guzzle\Http\Message\Request::onRequestError(Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#2 phar:///var/www/html/API/classes/opentok.phar/vendor/symfony/event-dispatcher/EventDispatcher.php(184): call_user_func(Array, Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#3 phar:///var/www/html/API/ in phar:///var/www/html/API/classes/opentok.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php on line 43
I've seen similar issues to this when the clock is out of sync with the OpenTok server. See OpenTok constructor/create_session fails when not running venv

How to test google market place api with php

I'm trying to use this api http://code.google.com/p/android-market-api/. I would like to get some that from play store. like App name, description, screenshots and download rating(total downloads, week downloads....)
I'm using the php version. I uploaded all the code to my personal server. www.example.com/test/.
Should I configure anything else in addition of local.php, email and password fields? I only did that.
I have this error:
Uncaught exception 'Exception' with message 'HTTP request returned code 400' in /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php:212 Stack trace:
#0 /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php(160): MarketSession->executeRawHttpQuery('??????DQAAAMkAA...')
#1 /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php(147): MarketSession->executeProtobuf(Object(Request))
#2 /homepages/31/d229886149/htdocs/carlos/test/examples/test_categories.php(15): MarketSession->execute(Object(Request_RequestGroup))
#3 {main} thrown in /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php
on line 212
Thank you.
After that I would like to implement it with codeIgniter
try with '0123456789123456' as an ANDROID_DEVICEID
define('GOOGLE_EMAIL','someone#gmail.com');
define('GOOGLE_PASSWD','SomePassword');
define('ANDROID_DEVICEID','0123456789123456');

Amazon soap interface using php

Hi i am trying to use soap to get results from amazon, and i havent tried this before so i was trying some sample code. The problem is i get an error.
the code is this:
<?php
#Use the NuSOAP php library
//require_once('lib/nusoap.php');
$params->AWSAccessKeyId = AMAZON_API_KEY;
$params->Request->SearchIndex = 'Books';
$params->Request->Keywords = 'php5';
$amazon = new SoapClient('http://webservices.amazon.com/AWSECommerceService /AWSECommerceService.wsdl');
$result = $amazon->itemSearch($params);
echo $result;
?>
and this is the error i get when i run it. thanx for your time
Fatal error: Uncaught SoapFault exception: [aws:Client.MissingParameter] The request must contain the parameter Signature. in C:\wamp\www\amasearch.php:11 Stack trace: #0 [internal function]: SoapClient->__call('itemSearch', Array) #1 C:\wamp\www\amasearch.php(11): SoapClient->itemSearch(Object(stdClass)) #2 {main} thrown in C:\wamp\www\amasearch.php on line 11
Weird. The WSDL doesn't have a signature parameter for any type. BUT, I found this in Amazon dev forums. Recommend you to check it out (also, if you develop using amazon services, keep that resource at hand
https://forums.aws.amazon.com/ann.jspa?annID=483
Looks like security gates for services are now taller and bigger, mate
EDIT: This question link to some example in C#. Maybe it can help you out Amazon (AWS) - The request must contain the parameter Signature
And this is an example in AWS forums with PHP https://forums.aws.amazon.com/message.jspa?messageID=149715

Categories