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.
Related
I am having a similar problem with Stripe webhooks. Spent all weekend trying to diagnose without success. Getting a general 500 error when running test through stripe dashboard. If I just load the page directly, it generates a blank page or if I echo something like echo http_response_code(200);, I get 200 back. My code is pretty straightforward.
require('/stripe/init.php');
\Stripe\Stripe::setApiKey("[intentionally deleted for post]");
$payload = file_get_contents("php://input");
$event_json = json_decode($payload);
http_response_code(200);
PHP runs fine on the site in all other contexts. There are no issues with implementing charges, both one time and subscriptions. Posts and Get work fine on all other pages. It's sharing hosting so have pretty limited access to error logs, etc...
I have already looked through the one or two stackoverflow responses to stripe webhook errors with through a 500 error but unfortunately these did not help. Thanks in advance.
I would try this kind of event creation:
$event = \Stripe\Webhook::constructEvent(
$request->getContent(),
$request->server->get('HTTP_STRIPE_SIGNATURE'),
$this->getParameter('stripe_webhook_secret')
);
This is Symfony code so $request is provided by Symfony but you can replace those with your native PHP variables. After this assignment, $event is populated with the data that you see in the Stripe docs examples.
we had a working facebook app with an own action that has been reviewed and been approved by facebook. Everything worked fine.
After changing the namespace and the title of the app, we now get an an error when sending the action via php sdk, althought all the action is still marked as approved and live.
$response = $facebook->api(
'me/myapp:create',
'POST', array('custom_object' => "http://www.myapp.com/metatags.php") );
This is the error we receive:
OAuthException: An unexpected error has occurred. Please retry your request later.
We've' already checked if the access token is vaild, it is!
Is it possible that facebook needs to re-approve custom actions after changing the namespace? Or does it need some time until it works again?
I dealt with this today, however my experience was in JavaScript, so I don't have relevant code to provide, you should be able to apply the same theory!
It seems that the error only happens once per access request - if you try to post again immediately after, it will usually be accepted by facebook with no error. Since the error code returned for unknown error is always the same, you can simply catch the error code from the response object and run the function again if it matches.
I'm writing a script, which fetches files from dropbox using it's REST API.
$this->oauth = new OAuth($consumer_key,$consumer_secret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$url = "https://api.dropbox.com/1/metadata/dropbox/";
$this->oauth->fetch($url);
Calls like these are working, so I get the authentication right. However the I can't get the thumbnails call working.
I have links like https://api-content.dropbox.com/1/thumbnails/dropbox/contact-support.jpg
That's an existing file, just fetched by the call above (which lists my files). My Dropbox app is in "full dropbox" mode, so "dropbox" as root should be OK too. I'm getting
"Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 403, expected HTTP/1.1 20X or a redirect)'..." errors constantly.
Any help would be appreciated, I'm starting to get frustrated by this.
Thanks a lot!
I have Pecl OAuth with PHP5 on a Debian box and I try to authenticate to LinkedIn. When calling;
OAuth->getAccessToken('https://api.lin...')\n#1
I get;
PHP Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)'
I have tried it from scratch and I have tried the PHP API wrappers that are available and (ofcourse, because they use OAuth Pecl ext) have all the same problem.
I read somewhere it might be the timestamp on the server, but I synched that up with ntpdate; it does that quite often now, so the offset with the timeservers is almost 0.
I tried this class first; http://www.linkedphp.com/2009/11/26/first-release-classes-to-connect-with-php-to-linkedin-api/, someone in the comments has the same problem, however the creator of the class says 'do you get a login screen'; I don't, I get a 'Grant or Deny' screen once, after that a blank screen and the above error in my logs.
What else can it be?
Thanks
Yep, confirmed. Timestamp IS the problem.
Make sure your server date/time is in sync with the rest of the world (i use Timeserver hostnames or addresses: ntp.cpsc.ucalgary.ca )
nb: I'm starting to think that this whole oauth thing is a bad , complicated thing :)
You should post your code.
Besides the timestamp issues, missing callbacl URL in the request can also cause this error.
Try using the format:
$access_token_info = $oauth->getAccessToken($accesstokenurl, "", $token);
where $token is the 5 digit confirmation code
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