OpenTok PHP SDK createSession not working - php

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

Related

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.

Google SSO aouth 2.0 gives Error fetching OAuth2 access token, message: 'invalid_grant: Code was already redeemed.'

I have sign in with google enable in my website it is working fine since last 3-4 month but from yesterday it start giving me following error on every 4-5 minuites
Fatal error: Uncaught exception 'Google_Auth_Exception' with message
'Error fetching OAuth2 access token, message: 'invalid_grant: Code was
already redeemed.'' in
F:\ServerFolders\Projects\domain.com\src\Google\Client.php(131):
Google_Auth_OAuth2->authenticate('4/8hj0saqecCytQ...', false) #1
F:\ServerFolders\Projects\domain.com\application\libraries\NV_gmail.php(105):
Google_Client->authenticate('4/8hj0saqecCytQ...') #2
F:\ServerFolders\Projects\domain.com\application\libraries\layout.php(51):
NV_gmail->login() #3
F:\ServerFolders\Projects\tl-l.com\application\controllers\dashboard.php(19):
layout->header() #4 [internal function]: dashboard->index() #5
F:\ServerFolders\Projects\domain.com\system\core\CodeIgniter.php(359):
call_user_func_array(Array, Array) #6
F:\ServerFolders\Projects\domain.com\index.php(202):
require_once('F:\ServerFolder...') #7 {main} thrown in
F:\ServerFolders\Projects\domain.com\src\Google\Auth\OAuth2.php on
line 126
And shows blank page .
When the user clicks authenticate you are given an authentication code. You take this code and exchange it for your access token and refresh token.
'invalid_grant: Code was already redeemed
Means that you are taking an authentication code that has already been used and trying to get another access token / refresh token for it.
If it has worked for the last 4 months my opinion is that someone changed something in your code and broke it.
Change
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
to
//curl_setopt($curl, CURLOPT_SSLVERSION, 3);
from curl.php according to github.com/google/google-api-php-client/issues/639 and now working fine

Facebook PHP API Error #100: Parameter 'input token' required

I have a Facebook app using the Login with Facebook function which was working earlier and isn't now.
I get the login URL with the following code:
$fb_helper = $login_providers['fb']->getRedirectLoginHelper();
$fb_login_url = $fb_helper->getLoginUrl(/* my callback URL */, array('email'));
At the callback URL, I then use $fb_helper->getAccessToken which returns the following exception.
Fatal error: Uncaught exception 'Facebook\Exceptions\FacebookAuthenticationException' with message '(#100) The parameter input_token is required' in /home/kgur5734/public_html/left/system/libraries/Facebook/Exceptions/FacebookResponseException.php:100
Stack trace:
#0 /home/kgur5734/public_html/left/system/libraries/Facebook/FacebookResponse.php(210): Facebook\Exceptions\FacebookResponseException::create(Object(Facebook\FacebookResponse))
#1 /home/kgur5734/public_html/left/system/libraries/Facebook/FacebookResponse.php(255): Facebook\FacebookResponse->makeException()
#2 /home/kgur5734/public_html/left/system/libraries/Facebook/FacebookResponse.php(82): Facebook\FacebookResponse->decodeBody()
#3 /home/kgur5734/public_html/left/system/libraries/Facebook/FacebookClient.php(225): Facebook\FacebookResponse->__construct(Object(Facebook\FacebookRequest), '{"error":{"mess...', 400, Array)
#4 /home/kgur5734/public_html/left/system/libraries/Facebook/Authentication/OAuth2Client.php(118): Facebook\FacebookClient->sendRequest(Object(F in /home/kgur5734/public_html/left/system/libraries/Facebook/Exceptions/FacebookResponseException.php on line 100
Any ideas, Stack Overflow?

Issue with createFulfillmentOrder Amazon MWS

I'm getting the following error while creating an order for canadian postal code: AB T5T 6V7.
PHP Fatal error: Uncaught exception 'FBAOutboundServiceMWS_Exception' with message 'Value for parameter DestinationAddress.PostalCode is invalid. Reason: InvalidValue.' in /Amazon/FBAOutboundServiceMWS/Client.php:970
Stack trace:
#0 /Amazon/FBAOutboundServiceMWS/Client.php(937): FBAOutboundServiceMWS_Client->_reportAnyErrors('<ErrorResponse ...', '400', Object(FBAOutboundServiceMWS_Model_ResponseHeaderMetadata))
#1 /Amazon/FBAOutboundServiceMWS/Client.php(178): FBAOutboundServiceMWS_Client->_invoke(Array)
#2 /Amazon/functions.inc.php(252): FBAOutboundServiceMWS_Client->createFulfillmentOrder(Object(FBAOutboundServiceMWS_Model_CreateFulfillmentOrderRequest))
#3 /amazon_automation.php(200): invokeCreateFulfillmentOrder(Object(FBAOutboundServiceMWS_Client), Object(FBAOutboundServiceMWS_Model_CreateFulfillmentOrderRequest))
#4 {main}
thrown in /Amazon/FBAOutboundServiceMWS/Client.php on line 970
But it is working for other Zipcodes of Canada.
Can anyone help me on this if I need to change some settings in my sellercentral?
I needed to explicitly check the state and resolve it before sending to FBA.

how to connect with salesforce using 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.

Categories