unable to add attachment to sharepoint list using ThyBAG api - php

Environment: Linux
Backend: Drupal/PHP.
Sharepoint API in use: https://github.com/thybag/PHP-SharePoint-Lists-API/
I have successfully established a connection with sharepoint using WSDL file. I am able to insert, delete and update the lists using the above API. But I am not able to add a attachment to the list item. I tried using the API function (addAttachment), but it is throwing the following error-
"Caught exception: Error (soap:Server) Exception of type
'Microsoft.SharePoint.SoapServer.SoapServerException' was
thrown.,more=Detailed: The security validation for this page is
invalid. Click Back in your Web browser, refresh the page, and try
your operation again."
Please let me know if anybody facing the same issue.
Thanks.

I got the solution for the above problem. The issue lies in this file
PHPSharePointListsAPI/src/Thybag/Auth/SharePointOnlineAuth.php on line 22
Just replace line 22 with the below code :-
$headers = array('SOAPAction: "' . $action . '"');
Hope that helps if anyone's stuck with it since ages.. :P

Related

Yii2 OpenId Connect error - yii2-authclient returns 400 error "Token not provided" when I try to getUserAttributes()

I'm implementing OpenId Connect into my Yii2 app using the yii2-authclient library. I can login and exchange the code for a token with no problems. I've followed most of the code examples on the web and set a successCallback function that gets called once a user successfully logs in. It looks like this:
public function successCallback(ClientInterface $client)
{
$attributes = $client->getUserAttributes();
}
This code gets called, but calling getUserAttributes() results in the following error:
Exception – yii\authclient\InvalidResponseException
Request failed with code: 400, message:
{"error":"invalid_request","error_description":"Token not provided"}
The logs on the id server show a blank client and user, with an error of invalid_token.
I took a close look at the request I make and I see an access_token element. Any ideas what the problem might be? I can provide more information if necessary.
I figured it out. The problem was that the yii2-authclient library was sending the token as a GET parameter and the ID server was expecting it as a POST param. I upgraded the yii2-authclient library and that solved the problem since a recent change sends the parameter as POST instead of GET.

The security validation for this page is invalid. attach a file through php sharepoint API

I have created basic webtool for candidate information using PHP Sharepoint API (Thybag).
I could do create the listitem. But I try to attach a file, i received this error.
Fatal error: Uncaught exception 'Exception' with message 'Error
(soap:Server) Exception of type
'Microsoft.SharePoint.SoapServer.SoapServerException' was
thrown.,more=Detailed: The security validation for this page is
invalid. Click Back in your Web browser, refresh the page, and try
your operation again.' in D:\wamp\www\jobs\SharePointAPI.php on line
1013.
I couldn't see any error report in github regards this.
This is code i try to execute: $sp->addAttachment('applicant', 21, "files/PID.txt");
all authentication process are done in while execute the PHP file.
Anybody can help this to resolve?
I was also facing similar issue. The issue lies in this file
PHPSharePointListsAPI/src/Thybag/Auth/SharePointOnlineAuth.php on line 22
Just replace line 22 with the below code :-
$headers = array('SOAPAction: "' . $action . '"');
Hope that helps.
Thanks.

Can't post new track via PHP Soundcloud API

I'm in a bit of a pickle here. I developped a Wordpress plugin that helps my site publish sounds to soundcloud directly from the WP back-office. The site has been live for about a year, and I have had no problems until now.
When uploading a track, I get a 'Fatal error: Uncaught exception 'Services_Soundcloud_Invalid_Http_Response_Code_Exception' with message 'The requested URL responded with HTTP code 422.'
I checked if nothing on my code had changed, and it hasn't, the request seems properly formed. Here is the bit of code:
$soundcloud->setAccessToken($_POST['access_token']);
$mytrack = array(
'track[title]' => $_POST["audioname"],
'track[asset_data]' => $_FILES["audiofile"]["tmp_name"]
);
$track = json_decode($soundcloud->post('tracks', $mytrack));
Any idea what could be wrong? I have a Pro Unlimited account, so I can't have reached a quota, can I? Other functions used through the API work properly...
If you are getting a 422 http code. That's 'Unprocessable entity' error acording to the docs. What it probably mean is that you data structure is wrong.
I don't know the php library you're using but I invite you to try out my own opensource library. https://github.com/njasm/soundcloud . Check the readme. You have an example on how to upload tracks.

Can't get Intuit Customer Data Aggregation API to work using PHP SDK/App

I just can't seem to use the SDK/Sample-app that Intuit recommends, found here.
I've attempted the simplest example.php included (and more), in many ways. No go.
Did anyone managed to get Intuit CAD PHP sdk working? If so, please share your experience.
Thanks!
I had the same issue on my local windows machine. I had to change curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0) on both the api call and class.aggcatauth.php
It appears that there is an issue with forming the signed_url using the oauthsimple.php 3rd party library. The oauth_signature appears to be missing and therefore causing the 400 error (MissingRequiredField).
Replace line 292 in oauthsimple.php with the following would solve the problem:
'signed_url' => $this->_path . '?' . $this->_normalizedParameters(),
An official fix has been pushed to the master branch by jrconlin. Please use the latest OAuthSimple.php to address the previously seen 400 (MissingRequiredField) error.
https://github.com/jrconlin/oauthsimple/tree/master/php

Can't get "Live Delegated Authentication" to work

I try to get the Live Delegated Authentication to work for the purpose of reading the email addresses.
I am doing this in PHP with the help of the windowslivelogin library. The problem is that I get an error.
I'm not sure what I'm doing wrong, i registered my application on the Azure webpage and got the appid and the secret into the code. This is what i use to initialize the Live Library :
$o = new WindowsLiveLogin();
$o->setAppId('000000004801B670');
$o->setSecret('secret');
$o->setSecurityAlgorithm('wsignin1.0');
$o->setDebug(true);
$o->setPolicyUrl('http://www.google.com/aides.html');
$o->setReturnUrl("http://michaelp.dev.gamepoint.net/framework/mainsite/contactimporter/?service=live");
return $o;
Then I call
$this->LiveLibrary->getLoginUrl()
And after I Login in to Live, it posts 2 things back, $_POST['stoken'] and $_POST['action'].
As soon as I call
$this->LiveLibrary->processLogin($_REQUEST);
It fails and gives back an error that the token is invalid.
I tried getting Consent straight away by making redirecting to
$this->LiveLibrary->getConsentUrl("Contacts.View");
But that gives an 3007 error and says that it cant share the information
According to MS this means the following :
3007
Consent Service API failed in the <method name> method. The application verifier is invalid.
The offer security level requires that a valid application verifier be passed with the request.
I am using the following URL, generated by the library
https://consent.live.com/Delegation.aspx?ps=Contacts.Invite&ru=http%3A%2F%2Fmichaelp.dev.gamepoint.net%2Fframework%2Fmainsite%2Fcontactimporter%2F%3Fservice%3Dlive&pl=http%3A%2F%2Fwww.google.com%2Faides.html&app=appid%3D000000004801B670%26ts%3D1251722931%26sig%3DD2gkM%252F%252FwlRXXfS64NMrV%252Bkt50v6dAOcESblfRk7j%252FUE%253D
I don't understand most of the documentation Microsoft has on this thing, I think its really unclear and chaotic. Also the Sample I tried doesn't work. I get an error message, it can't validate/decode the token. Same I get when I try the processLogin().
Thanks in Advance,
Michael

Categories