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
Related
I am re-asking this question. The original occurrence went away after retrying the post, but on Dec 9, it has happened again, with greater frequency. I now have over 140 requests backed up that are failing with this same error inside the Facebook PHP API, and retrying the posts still fails. Dumping out the value of $rawResponse header shows:
{"
Just a left brace followed by a double quote, so it looks like the original function response is probably some JSON. Not sure what function made the original call, looking into that if I can make this happen in my DEV environment.
So, I just got back from vacation, and find that the Facebook PHP API was throwing this error:
Undefined offset: 1 in /home/httpd/idxv3/lib/Facebook-v5/Http/GraphRawResponse.php on line 108
The line is in this function:
public function
setHttpResponseCodeFromHeader($rawResponseHeader)
{
preg_match('|HTTP/\d\.\d\s+(\d+)\s+.*|', $rawResponseHeader, $match);
$this->httpResponseCode = (int)$match[1]; // <---- HERE
}
Other than the dangerous programming, why is this suddenly happening?
Ok, I believe that I have determined the problem. I recreated my Facebook API post inside the debugger, and determined that there is a block on the particular page I am posting to - but Facebook is returning a block of JSON code, which the API can't seem to handle. So, my question is moot - the API isn't written to handle the return values it might be getting from Facebook. Lovely.
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.
I am newbie in Prestashop module development so sorry if it is a fool question... I have been reading the docs but I haven't found what I am looking for so here I go,
I'd like to show a message on the screen (just for debugging purpose) with different context vars and so forth when actionCartSave. Something similar to "console.log()" or "alert()" in js.
Impossible to add the product to the cart.
textStatus: 'parsererror'
errorThrown: 'SyntaxError: JSON Parse error: Unrecognized token '<''
responseText:
< xmp style="text-align: left;" > message: < /xmp>
*{
"products": [...] *
I have already test this code:
public function hookActionCartSave( $params )
{
ppp('message: ');
return true;
}
...inside the module class definition but I am getting this error when I add a product to the cart:
I get this text in a different browser window.
So please, what is the best way to go?
Hope everything is clear. Thanks.
What you have done is correct, this error message is something thrown by javascript running in your browser since the additional information you are printing out using ppp isn't valid JSON.
If you use Chrome, use developer tools and select the Network tab. You will see the ajax call here. You can inspect this call in more detail by clicking on it.
Not sure it's the best option, but I found it useful to debug with a simple
throw new Exception('Custom message ' . $someVariable);
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.
I think the Mod-Auth-SSPI is conflicting my ajax system. Please find the below code -
new Ajax.Request(ajaxUrl,
{
method:'post',
parameters: 'json='+json,
onSuccess:
function(transport)
{
if (transport.responseText.isJSON())
displayInfo(transport.responseText.evalJSON(true)); // error occurs
else
alert('Damn! It's not working...');
},
onFailure:
function()
{
alert(mateErrAjaxUrl)
}
});
it always returns the alert('Damn! It's not working...'). That means the displayInfo is not working or conflicting with something. Can anyone tell me how to resolve it ?
Please note that, Mod-Auth-SSPI is working correctly as per my need.
I had a similar problem with Ajax and Internet Explorer (v6 and 8).
If you watch the network traffic, you can see that IE begins by sending an empty POST request (content-length: 0) that trigger the NTLM auth, then send the correct POST with the full body.
The bug happens when IE uses an already established TCP/IP connection to Apache/mod_auth_sspi. With the default settings, mod_auth_sspi let the empty POST request pass through, since the connection has been authentified. And your app receive an empty POST request, which probably puzzles it.
One of the solution is to add the instruction 'SSPIPerRequestAuth On' in your Apache config, as said here :
http://wiki.apache.org/httpd/ModAuthSSPI
(at the time of this writing, the /doc in the source of mod_auth_sspi is unfortunately not up to date)
One other, on a old mod_sspi install, was to add 'MaxKeepAliveRequests 2' and 'KeepAliveTimeout 1', which is dirty but could come to help.