I've asked the owner for the project for some help, but thought I'd ask stack overflow as well.
Does anyone know how to correctly add a track using the spotify-api-server? I'm sure i'm missing something simple:
Could you please tell me how to POST and add a track to a playlist? I keep getting an error no matter what I try. If i try and POST the URI as detailed in the readme, it errors:
["spotify:track:1lDWb6b6ieDQ2xT7ewTC3G"]
error: {"message":"Invalid input"}
["1lDWb6b6ieDQ2xT7ewTC3G"]
error: {"message":"No valid tracks"}
```
If I try and POST to localhost:1337/playlist/{playlist ID}/add?index I get the error {"message":"Bad parameter: index must be numeric"}. It's only after changing index to index=1 does it let me move on and attempt to add a track. Is this correct?
I'm doing this through PHP, but happy to see terminal commands that I can try out and then adapt.
Regarding {"message":"Bad parameter: index must be numeric"}, yes, that's correct — that's the index at which the track will be inserted into the playlist. 0 will make it the first item.
Related
I am trying to make a test transaction using my Laravel 7 app and Authorize.net.
After submitting the sample data, I'm getting:
The element 'createTransactionRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'clientId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
Anyone know what's causing this error or how to fix it?
Well, I'll answer my own question since it might help others. The problem is the error message in the Authorize.net response is really vague.
Kurt Friars' comment was helpful, since it pointed me in the right direction. As for Mansour Hamcherif's suggestion, the merchantAuthentication object was set in my app, it just didn't have the right values, so it wasn't that.
The solution for me was setting the proper values to setName() and setTransactionKey(). The previous developer who had worked on this project had left values and the credentials had expired. I did a Linux text search for "setTransactionKey", which lead me to the correct PHP file where I need to set:
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName('EnterYourLoginNameHere');
$merchantAuthentication->setTransactionKey('EnterYourTransactionKey');
After that, I cleared all of my Laravel app's caches as well as my browser's caches, did a hard reload, tried a transaction again and it worked! I got:
This transaction has been approved., Transaction ID: **********.
You may want to check the log for the raw request, it's likely the merchantAuthentication object has not been set, if you are using the PHP SDK I recommend checking the SimpleCodeConstants.php file and make sure your merchant credentials constants are set.
For example, if I set my merchant credentials to NULL, I get the same E00003 error as a result of sending the following raw request:
{"createTransactionRequest":{"merchantAuthentication":[],"clientId":"sdk-php-2.0.0-ALPHA", ...}
I'm currently using the "Isitup" slack slash command example authored by David McCreath (more here": https://github.com/mccreath/isitup-for-slack/blob/master/isitup.php).
Within this code, I am wondering how I would go about making the response go from appearing "only to me" to posting in to the entire channel, along with the query posted by the user. I've read the slack documentation which shows the "in_channel" parameter that needs to be added, however I am just not that strong with code so I'm really not sure where I should input this in to the code I've got.
I'm sure this is a simple fix - can someone provide assistance? I've searched everywhere and can't seem to find a comprehensive answer.
As you correctly mentioned the trick is to reply to Slack by setting the property response_type to in_channel.
The current code (as per your github link) is replaying to Slack with a simple plain text in the following line:
echo $reply;
In order to set the response_type property it needs to reply with a JSON array instead that should look like this:
{
"response_type": "in_channel",
"text": "It's 80 degrees right now."
}
All you need to do is build a PHP array with those two properties, convert it to JSON with json_encode() and send it back to Slack instead of the plain text.
I trying to build a server using laravel and pubnub, but the page always show a blank page, and after i look at the response it seems there is something wrong on pubnub.php (http response : 500)
and after I open dist/pubnub.php, it always said:
"PubnubException in Pubnub.php line 93: Missing required $subscribe_key param"
and after some searching, I found that I need to get a pub_key and sub_key, now for the question, what should I do to fix this error? how to init the pubnub? and of course I have search something about this but all of them still lead me to a dead end.
Register at pubnub.com, get your keys and use them when init:
This is the format:
$pubnub = new Pubnub($publish_key, $subscribe_key, $secret_key)
For more details:
https://www.pubnub.com/docs/php/pubnub-php-sdk#init
I am having troubles with my PHP application which uses Drive SDK. I am trying to update a file, but all the time I receive 500 Internal Error message when I try to update file's contents.
I am looking for some way to debug the application. What would be most helpful for me is possibility to view how the entire request along with all headers look like. Is there any way to check it, or are there any other options for debugging?
Thank you a lot for your time.
I still didn't find any option for debugging- However, I found how I can view the requests done by the API client.
Open google-api-php-client/io/Google_REST.php file and find static public function execute(Google_HttpRequest $req) function.
There you will find this line:
$httpRequest = Google_Client::$io->makeRequest($req);
Right under it put the following code: var_dump($httpRequest);
During every request the client will do, you will get dump of it's request.
This question is still relevant but the accepted answer is very old. If you wish to view the HTTP requests and server responses in version three, the file you need to edit is /vendor/google/apiclient/src/Google/Http/REST.php. Locate the doExecute function and add print_r($request->getUri()); to the first line. Add print_r($response->getBody()->read(1024)); to the line just before the function returns to see the response body.
I'm creating a global high score table. The JavaScript sends the username and score to the PHP through some AJAX functions and POST. The PHP script then takes the variable, and compares the score values to the file on the server. It then puts the new score where it should go on the score table, and rewrites the file.
I had it working last night, but now, when I call the function, it displays my code instead, and firebug gives the error, "No element found". I'm not sure what I did between then and now, but I just can't figure this one out.
This is my first time using PHP and AJAX, so I'm not sure where or what the error is.
Any help would be appreciated!
The exact error:
Timestamp: 4/13/2013 1:59:18 PM
Error: no element found
Source File: file:///C:/wamp/www/ajax.php
Line: 84, Column: 3
Source Code:
?>
If I cannot help you solve this issue, I will delete this answer, but I wanted to post it like this so you can better read my suggestions.
Start by changing your HandleResponse function to this:
function HandleResponse(response)
{
console.log(response);
document.getElementById('ResponseDiv').innerHTML = response;
}
and post the result that appears above the error, in firebug.
What we are doing here is adding a way for us to see if any data was actually returned from the AJAX request. A call to console.log tells the browser to print the given argument to the console (in your case, firebug).
UPDATE 1
In your comments, you stated that nothing displayed when you logged the value of response. This means that you received nothing back from the server (in terms of data, at least).
My next suggestion is that you change the call to MakeRequest to the following:
<input type='button' id="test" onclick='MakeRequest("*");' value='Global Highscore Table'/>
Like before, leave the console.log line in the HandleResponse method, and post the result that appears above the error in firebug.
Here, we are setting your MakeRequest to make a request that passes a wild-card query parameter. At the time of this suggestion, I did not realize that the requested file expected two arguments, nor that passing a wild-card would error the script. However, this was still a good thing to do, as we found a new error, which tells us that the request is being received.
UPDATE 2
Now, cut and paste everything from your "ajax.php" file to your notepad or another, similar application. Then, set the following to be the only content of the "ajax.php" file:
<?php echo "Request received and response sent"; ?>
Again, post the result of the console.log.
Here, we are taking a step back from fixing the complex code, and we are going back to the basics. All we want to do, here, is verify that we can both send the request and receive a response.
If "Request received and response sent" is successfully returned as the response of the request, then we know that the error lies in ajax.php, and not in the request. If it is not, we know that there is a problem with the request (be it a server issue or the request, itself). If the latter is the case, there could still be a problem with ajax.php, but we must first fix the request.
UPDATE 3 (final solution)
Issue was found to be due to not correctly running on the local server.