SoapClient in PHP throwing SoapFault exception: [HTTP] Forbidde - php

I am completely inexperience with this whole SOAP concept so I have no idea what to look for when I see an error.
So basically I am trying to pull some data from another company. That company gave me a digital certificate and and some xsd & wsdl files and asked me for my server's IP so they could whitelist it. As I mentioned, I have no idea what to do with the files they gave me, so I uploaded them to my server and then I started googling, and I have pasted together the following code (although I don't even know if it makes sense):
$protected_url = "http://www.myurl.com/WSDLFILE.wsdl";
$my_cert_file = "http://www.myurl.com/CERTFILE.pem";
$client = new SoapClient($protected_url, array('local_cert'=> $my_cert_file,'trace'=>1));
$params->Affiliate->AffiliateID = 555;
$params->Address->AddressLine = "123 Main Street";
$params->Contact = 'No';
$result = $client->QueryAddress($params);
And I get the following error
[10-Apr-2013 18:59:46 America/New_York] PHP Fatal error: Uncaught SoapFault exception: [HTTP] Forbidden in /home/mysite/index.php:15
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://secure....', 'http://www....', 1, 0)
#1 /home/mysite/index.php(15): SoapClient->__call('QueryAddress', Array)
#2 /home/mysite/index.php(15): SoapClient->QueryAddress(Object(stdClass))
#3 {main}
thrown in /home/mysite/index.php on line 15
It's kind of hard to search for help because I dont even know what I'm searching for, so any guidance is appreciated
EDIT: I should also add that I have actually been able to get a successful response by using cURL and setting the "CURLOPT_SSLCERT" option, but I need to use SOAP

(Answered in the comments. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
SOLVED: My problem was the way I was using the .wsdl file. I thought I had to upload the one they provided and then use it when creating the SoapClient, but that was not the case. What I needed to was reference their wsdl url, which ended in something like https:......asmx?WSDL

Related

I'm try using Spotify PHP api

I'm try to use api from
https://github.com/jwilsson/spotify-web-api-php/blob/main/docs/examples/access-token-with-authorization-code-flow.md.
Unfortunately, it doesn't work well because it gets such an error
Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIAuthException: Invalid redirect URI in D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php:56 Stack trace: #0 D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php(244): SpotifyWebAPI\Request->handleResponseError('{"error":"inval...', 400) #1 D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php(112): SpotifyWebAPI\Request->send('POST', 'https://account...', 'client_id=48f0c...', 'HTTP/2 400 \r\nda...') #2 D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Session.php(250): SpotifyWebAPI\Request->account('POST', '/api/token', Array, Array) #3 D:\Software\Development\XAMPP\htdocs\spotif\auth\app\check.php(26): SpotifyWebAPI\Session->requestAccessToken('AQA9X84L0SDucXG...', 'a86937efa85589a...') #4 {main} thrown in D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php on line 56
I tried to solve the problem with all methods,but even if in the console of my Spotify application.
I have everything set up well, like the redirect URI in my PHP code, I still get an error.
Changing the redirectURI doesn't help me in any way.
Wait some hours/days fixing my problem

GAPI: Failed to request report data and provides no further information

We're using the PHP GAPI ([https://code.google.com/p/gapi-google-analytics-php-interface/) to retrieve data and to show graphs in admin panel of our websites.
We know this library hasn’t been updated since 2009, but it was working fine for us for a long time until some months ago...
Bellow is the error we got :
Fatal error:
Uncaught exception 'Exception' with message 'GAPI: Failed to request report data.
Error: "Request failed, fopen provides no further information"' in /www/clientname/site/lacentrale/gapi.class.php:218
Stack trace:
#0 /www/clientname/site/cms/include.dashboard.analytics.visits.php(37): gapi->requestReportData('95220065', Array, Array, Array, NULL, '2014-11-23', '2014-12-22', 1, 30)
...
#6 {main} thrown in /www/clientname/site/cms/gapi.class.php on line 218
Here is the code for include.dashboard.analytics.visits.php — lines 35 to 39 (error on line 37):
if ( ! $ga = $myCache->getCache() ){
$ga = new gapi(ga_email,ga_password);
$ga->requestReportData(ga_profile_id,array($dimension),array('visits','pageviews','timeOnSite','avgTimeOnSite','pageviewsPerVisit'),array($dimension),null,$begin,$end,1,$max);
$myCache->saveCache($ga);
}
And here is the code for gapi.class.php — lines 212 to 219 (error on line 218):
if(substr($response['code'],0,1) == '2')
{
return $this->reportObjectMapper($response['body']);
}
else
{
throw new Exception('GAPI: Failed to request report data. Error: "' . strip_tags($response['body']) . '"');
}
We don’t fully understand these errors which are not so clear, and as nothing changed in these files...
As we seen on other StackOverflow tickets and other forums, we've already checked our profile ID which is the good one (8 digits after the p in the Google Analytics URL).
We would like to not move to another PHP API for GA (if any other available? what would be the best solution as of today?) because it would required a lot a work to implement again the admin panel we've made ...
Many thanks for your help!
Problem solved : we had made modifications into the gapi.class.php file since a long time for a project which required special securised specifications for server connection and we were still using this file modified in other projects which do not required this modifications...
So we downloaded a clean copy of GAPI and replaced with the initial file to solve the problem ;-)

CHttpException when trying to submit a form with a captcha

I'm new to the yii framework and I am trying to execute a php application in my local zwamp environment. The application works correctly in a production environnent.
The Error I receive is after filling the form and trying to submit it. The captcha doesn't validate and I get the following error in the logs:
2014/11/10 10:23:17 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system cannot find the action « undefined » that is requested.' in D:\Users\....\web\CController.php:483
Stack trace:
#0 D:\Users\...\web\CController.php(270): CController->missingAction('undefined')
#1 D:\Users\...\web\CWebApplication.php(282): CController->run('undefined')
#2 D:\Users\...\web\CWebApplication.php(141): CWebApplication->runController('site/undefined')
#3 D:\Users\...\base\CApplication.php(180): CWebApplication->processRequest()
#4 D:\Users\....\index.php(23): CApplication->run()
#5 {main}
REQUEST_URI=/appname/site/undefined
HTTP_REFERER=http://localhost:92/appname/site/form
How can I fix this or identify which action is causing the problem?
**EDIT: problem seems to come from here : the verification code does not match the image displayed.. **
/**
* Gets the verification code.
* #param boolean $regenerate whether the verification code should be regenerated.
* #return string the verification code.
*/
public function getVerifyCode($regenerate=false)
{
if($this->fixedVerifyCode !== null)
return $this->fixedVerifyCode;
$session = Yii::app()->session;
$session->open();
$name = $this->getSessionKey();
if($session[$name] === null || $regenerate)
{
$session[$name] = $this->generateVerifyCode();
$session[$name . 'count'] = 1;
}
$message = $session[$name];
echo "<script type='text/javascript'>alert('$message');</script>";
return $session[$name];
}
what could be the issue?
Ayrad, the error message is quite ambiguous saying like, "...action « undefined ».....", in general Yii 404 errors specifies name of it (for example, "...Unable to resolve the request "ABC XYZ ...." ).
These kind of errors depend on many things, like, was engine rewrite was enabled, how is your .htacess. At least, how is your "URLManager" looks in your Config.
So, my answer is from my experience from the problem which I faced earlier. Their are some broken links in my CSS file, so I got error likes this,
[error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system is unable to find the requested action "undefined".' in C:\wamp\yii\framework\web\CController.php:484
Stack trace:
#0 C:\wamp\yii\framework\web\CController.php(271): CController->missingAction('undefined')
#1 C:\wamp\yii\framework\web\CWebApplication.php(283): CController->run('undefined')
#2 C:\wamp\yii\framework\web\CWebApplication.php(142): CWebApplication->runController('site/undefined')
#3 C:\wamp\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
#4 C:\wamp\www\index.php(27): CApplication->run()
#5 {main}
REQUEST_URI=/site/undefined
HTTP_REFERER=http://localhost/site/index
I checked my main layout and find out this buggy javascript function causes that error:
$(".shortcuts").each(function(){
var cacheImage = document.createElement('img');
cacheImage.src = $(this).attr('rel');
cache.push(cacheImage);
});
It was suppose to preload shortcuts images on the bootstrap navbar. so that fixed the problem. Hope this helps. if not, please try to post extra details.
Error logs show clearly what this is about,
REQUEST_URI=/appname/site/undefined
this shows that somehow you generated a url like that and when it was trying to resolve using that, it faild (I think it's your forms url)
you have to share to view that made this form, otherwise we can't help you
If this code working correctly in production environment. Then the issue may be due to mismatch of database or main.php. I think, this error is due to not getting the site action correctly. check that, the requesting URL is given correctly.

creating events through zend

in my server i downloaded and uploaded the zend gdata library.then as a test i created a seperated folder and checked whether its working. and yes it worked.so i kept the folder structure as it is and moved the files in to my app. then it gave me an error like this.even if i tried the same code which i used in the test folder, it gives me the same error.please help me.
error
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 [Line 1, Column 451, element gd:when] Badly formatted datetime' in /var/www/vhosts/eyepax.info/rsdesign.eyepax.info/emailApp2/Zend/Gdata/App.php:714 Stack trace: #0 /var/www/vhosts/eyepax.info/[host]/emailApp2/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'https://www.goo...', Array, 'performHttpRequest('POST', 'https://www.goo...', Array, 'performHttpRequest('POST', 'https://www.goo...', Array, 'performHttpRequest('POST', 'https://www.goo...', Array in /var/www/vhosts/eyepax.info/[host]/emailApp2/Zend/Gdata/App.php on line 714
if this is a fault with the library, please tell me what to do..
in the test folder i have 2 files and the folder named Zend...i used the following code as a class and used it's example code to test it.and it worked. my problem is why is it not working in my app?
class=http://www.phpclasses.org/browse/file/28780.html
i received this error for several reasons. my time offset was not correct.and the way i entered the time was incorrect aswell. it should be HH:MM:SS not HH.MM.SS . hope this helps someone

"No servers found" using openid light

All of a sudden i'm getting this error message using Light Open ID.
Fatal error: Uncaught exception 'ErrorException' with message 'No servers found!' in /home/a3422801/public_html/LoginAssignment/php/openid.php:463 Stack trace: #0 /home/a3422801/public_html/LoginAssignment/php/openid.php(595): LightOpenID->discover() #1 /home/a3422801/public_html/LoginAssignment/index.php(9): LightOpenID->authUrl() #2 {main} thrown in /home/a3422801/public_html/LoginAssignment/php/openid.php on line 463
...and the small snippet of relevant code in openid.php:
if ($server) {
# We found an OpenID2 OP Endpoint
if ($delegate) {
# We have also found an OP-Local ID.
$this->identity = $delegate;
}
$this->server = $server;
return $server;
}
throw new ErrorException('No servers found!');
I have no idea what the problem is - this is a recent issue. Does anyone know has something changed recently with OpenID. I'll gladly provide any more code that is required. I'm new with logins and PHP in general so i apologize if this is very vague.
This google login is coupled with a FB login if this has any bearing - but like i said, this was functioning correctly.
I had the same problem, and solved it by comparing the OpenID URL I was using, with the one here on StackOverflow. Turns out I wasn't using https. Until recently, this was not a problem, but now it seems to be required.
So make sure you're using the following URL:
https://www.google.com/accounts/o8/id
After changing this, it works again at my websites.

Categories