A few days ago I released a beta version of a game on Facebook.
Unfortunately, I'm not so lucky, and in the first most important days of the application when users first use it, they keep getting errors resulting from errors on my PHP Apache server which gets the following errors from Facebook API -
couldn't connect to host
connect() timed out!
My server runs on a free server I got from Joyent for facebook developers.
I'm not a big expert with web servers so I got no idea if the problems are from my side or Facebook side.
And how can I fix this problem quickly!
Thanks a lot!
Edit:
For some reason I forgot about the code samples and error examples -
Here's an example for a simple query against facebook -
$session = $facebook->getSession();
$currentID = $facebook->api('/me?fields=id');
Here's the error stack trace -
couldn't connect to host StackTrace: Array
(
[0] => Array
(
[file] => /users/home/aagnt2sv/web/public/Facebook/facebook-php-sdk-7d538d3/src/facebook.php
[line] => 523
[function] => makeRequest
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => https://graph.facebook.com/me?fields=id
[1] => Array
(
[method] => GET
[access_token] => 104269778819|2.AQAKqpIXE0jqFuoU.3600.1311008400.1-785849095|qxtBqmWWRMc_GpM77CK77RbO4YA
)
)
)
[1] => Array
(
[file] => /users/home/aagnt2sv/web/public/Facebook/facebook-php-sdk-7d538d3/src/facebook.php
[line] => 491
[function] => _oauthRequest
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => https://graph.facebook.com/me?fields=id
[1] => Array
(
[method] => GET
)
)
)
[2] => Array
(
[function] => _graph
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => /me?fields=id
)
)
[3] => Array
(
[file] => /users/home/aagnt2sv/web/public/Facebook/facebook-php-sdk-7d538d3/src/facebook.php
[line] => 444
[function] => call_user_func_array
[args] => Array
(
[0] => Array
(
[0] => Facebook Object
(
[appId:protected] => *censored*
[apiSecret:protected] => *censored*
[session:protected] => Array
(
[uid] => *censored*
[access_token] => 104269778819|2.AQAKqpIXE0jqFuoU.3600.1311008400.1-785849095|qxtBqmWWRMc_GpM77CK77RbO4YA
[expires] => 1311008400
[sig] => ddf14dcaa953cb64d3f98b0649b60613
)
[signedRequest:protected] =>
[sessionLoaded:protected] => 1
[cookieSupport:protected] => 1
[baseDomain:protected] =>
)
[1] => _graph
)
[1] => Array
(
[0] => /me?fields=id
)
)
)
[4] => Array
(
[file] => /users/home/aagnt2sv/web/public/edamometer/EdamometerWS.php
[line] => 31
[function] => api
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => /me?fields=id
)
)
Thanks again!
This was somehow fixed by itself after several days. Maybe it was a temporary problem on my server or on Facebook's servers.
Get user id with
$fb = new Facebook(array(
'appId' => 'your_app_id',
'secret' => 'your_app_secret',
));
$user = $fb->getUser();// returns user id
I'm currently having this problem with my server (using PHP to access the Facebook API), as well. Based upon the nature of the error message, obviously the problem is the connection between my server (running on the Amazon cloud, btw) and Facebook's server(s).
What is throwing me for a loop, though, is that some commands are working properly. That is, attempting to log in with one Facebook token is working fine, while another in causing this error message.
The only reasonable explanation I can come up with is that the Facebook servers are experiencing some sort of temporary hiccup... but even that does a poor job of explaining the problem, since it is somehow tied to the token which is being used. The only way it makes sense is if there's some sort of bug where Facebook's servers are timing out in processing the specific token I'm giving them...
Related
I'm trying to get the last posts of a subreddit - I'm using the jcleblanc reddit sdk (https://github.com/jcleblanc/reddit-php-sdk) and I don't know why It's not working - I receive the following message ewhen I try to acess my website
403 Forbidden
Request forbidden by administrative rules.
The https://ssl.reddit.com/prefs/apps is configured okay - I just don't know why It's not working. I'm using the following function:
<?php
$reddit = new reddit();
$response = $reddit->getListing("calculus", 5);
print $response
?>
It'd be nice to have some help - I'm not any expert developer, just trying to make something.
Thanks :-)
Hey guys - I managed to get it working using an old version of that don't uses OAuth.
$reddit = new reddit($USER, $PASS);
print_r($reddit);
print_r($reddit->getListing("calculus", 1));
It's working! but, on the page I receive all the information, for example:
reddit Object ( [kind] => Listing [data] => stdClass Object ( [modhash] => jvfddbr7sg6a1787beebf94c0a61cc4c2be6e5fb2106da9f4b [children] => Array ( [0] => stdClass Object ( [kind] => t3 [data] => stdClass Object ( [domain] => self.leagueoflegends [banned_by] => [media_embed] => stdClass Object ( ) [subreddit] => leagueoflegends [selftext_html] => [selftext] => [likes] => [user_reports] => Array ( ) [secure_media] => [link_flair_text] => [id] => 2papx0 [gilded] => 0 [secure_media_embed] => stdClass Object ( ) [clicked] => [report_reasons] => [author] => Azberg [media] => [score] => 2217 [approved_by] => [over_18] => [hidden] => [thumbnail] => self [subreddit_id] =>
I'd like to know how can I select only some of the items abovve - like domain, or likes, or anything. I tried but I can't manage it to work. Sorry for the newbiness - I really tried to fix this.
Thanks in advvance!
You should always use the latest API. Anyways, did you fill out the information in config.php?
According to the documentation, you have to "post the key and secret into the appropriate sections" in your config.php which is this file:
https://github.com/jcleblanc/reddit-php-sdk/blob/master/config.php
Specifically these two variables
...
static $CLIENT_ID = 'YOUR CLIENT ID';
static $CLIENT_SECRET = 'YOUR CLIENT SECRET';
...
I'm using the Facebook SDK and we created an app which worked just as we needed. We could $FacebookSDK->getSignedRequest() in PHP and it would respond with an object that included pages->liked which allowed us to determine if the user likes the page or not.
Anyway, we have created an exact duplicate application (the only difference being that this app is about 3 months newer than the old) and the like property has completely disappeared and I can't get my hands on it.
Any ideas why this is happening - has Facebook restricted their SDK yet further and removed this property for new apps?
Example Before:
stdClass Object
(
[algorithm] => HMAC-SHA256
[issued_at] => 1408626697
[page] => stdClass Object
(
[id] => ************
[admin] => 1
[liked] => 1
)
[user] => stdClass Object
(
[country] => gb
[locale] => en_GB
[age] => stdClass Object
(
[min] => 21
)
)
)
Example After:
stdClass Object
(
[algorithm] => HMAC-SHA256
[issued_at] => 1408625335
[page] => stdClass Object
(
[id] => ************
[admin] => 1
)
[user] => stdClass Object
(
[country] => gb
[locale] => en_GB
[age] => stdClass Object
(
[min] => 21
)
)
)
Notice that the only thing missing here is the likes property so I can't tell if the user likes our page tab or not! Facebook is doing my nut in to develop on these days!
Thanks,
Chris.
https://developers.facebook.com/docs/apps/changelog
(see v2.1 changes)
Fan-/Like-Gates are not possible anymore, and not allowed according to the Platform Policy. Old Apps will always return "true" in the signed_request parameter after 5th of November 2014.
i have create yii framework based wsdl service:
from the link :-
http://www.yiiframework.com/doc/guide/1.1/en/topics.webservice
and facing the issues that is their in the comment
http://www.yiiframework.com/doc/guide/1.1/en/topics.webservice#c6656
and server create fine as i am able to see the wsdl file
but when i try to access the method by the code from external file not in yii site folder
below file is inside another folder not in mysite_yii folder hope that not create any issue as it has to call the wsdl file
$client=new SoapClient('http://localhost/mysite_yii/index.php?r=stock/quote');
try
{
echo $client->getPrice('GOOGLE');
}
catch(Exception $e)
{
echo "<pre>";
print_r($e);
}
i am getting the following exception
SoapFault Object
(
[message:protected] => Function ("getPrice") is not a valid method for this service
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /var/www/serverclient/stock.php
[line:protected] => 9
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /var/www/serverclient/stock.php
[line] => 9
[function] => __call
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => getPrice
[1] => Array
(
[0] => GOOGLE
)
)
)
[1] => Array
(
[file] => /var/www/serverclient/stock.php
[line] => 9
[function] => getPrice
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => GOOGLE
)
)
)
[previous:Exception:private] =>
[faultstring] => Function ("getPrice") is not a valid method for this service
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)
i have done the same changes as suggested in the comment but not able to call that method
any suggestions ?
Thanks in advance
you must off the server cache for soap, u can off it by adding
ini_set("soap.wsdl_cache_enabled", "0"); to your code
so heres my predicament.
Currently using Yahoo API with PHP in order to use a 'Login with Yahoo' Function on my site.
I have managed to retrieve my entire profile. Trouble is, I can't directly display the primary email associated with the account.
If I use print_r($profile) I get everything dumped from my profile. It looks like this (personal data removed):
stdClass Object ( [uri] => http://social.yahooapis.com/v1/user/*********/profile [guid] => ***** [birthdate] => / [created] => 2010-04-22T20:47:48Z [emails] => Array ( [0] => stdClass Object ( [handle] => **#gmail.com [id] => 1 [type] => HOME ) [1] => stdClass Object ( [handle] => ****#yahoo.com [id] => 2 [primary] => 1 [type] => HOME ) ) [familyName] => Surname [gender] => M [givenName] => Ricki [image] => stdClass Object ( [height] => 192 [imageUrl] => http://l.yimg.com/dh/ap/social/profile/profile_b192.png [size] => 192x192 [width] => 192 ) [lang] => en-US [memberSince] => 2010-04-08T11:22:56Z [nickname] => Ricki [profileUrl] => http://profile.yahoo.com/*********** [updated] => 2013-03-03T18:12:22Z [isConnected] => )
Using $profile->emails->handle yields nothing however. Any ideas on what to do? I can use $profile->emails which returns an Array, displayed simply as 'Array' but if i try to select from the array i get an error:
"Catchable fatal error: Object of class stdClass could not be converted to string"
Anyone?
$profile->emails[0]->handle will give you the first handle in the system.
You can also do foreach($profile->emails as $email) { print $email->handle; }
Take the following JSON string (generated by some ExtJS code - but that's irrelevant):
[{"action":"Setting","method":"toggle","data":["welcome-home"],"type":"rpc","tid":2},{"action":"ContentExtFeFillout","method":"todo","data":[true,0,8,false],"type":"rpc","tid":3}]
being sent to a server as a POST request and retrieved via $GLOBALS['HTTP_RAW_POST_DATA'].
Running
json_decode($GLOBALS['HTTP_RAW_POST_DATA']);
on our development machine (5.2.10-2ubuntu6.4 with Suhosin Patch 0.9.7) gives a correct print_r() output of:
Array
(
[0] => stdClass Object
(
[action] => Setting
[method] => toggle
[data] => Array
(
[0] => welcome-home
)
[type] => rpc
[tid] => 2
)
[1] => stdClass Object
(
[action] => ContentExtFeFillout
[method] => todo
[data] => Array
(
[0] => 1
[1] => 0
[2] => 8
[3] =>
)
[type] => rpc
[tid] => 3
)
)
Running the same code on a client's production machine (5.2.5 with Suhosin Patch 0.9.6.2 and Zend Optimizer; SUSE Linux by the way) gives the following print_r() output:
Array
(
[0] => stdClass Object
(
[action] => Setting
[method] => toggle
[data] => Array
(
[0] => welcome-home
)
[type] => rpc
)
[1] => 2
[2] => stdClass Object
(
[action] => ContentExtFeFillout
[method] => todo
[data] => Array
(
[0] => 1
[1] => 0
[2] => 8
[3] =>
)
[type] => rpc
)
[3] => 3
)
Note the missing tid property which obviously has been moved into the main array as an own value - this naturally breaks all the following code.
We also downloaded a Windows PHP version 5.2.5 to check if there's a bug in json_decode() but we get the correct output here.
Are there any known issues with json_decode() at all that could cause this odd behavior?
We're currently totally clueless...
Thanks to all of you!
Best regards
Stefan
OK guys - problem solved. Lacking any more options we persuaded the client to update the installed PHP version and guess what: it works.
There seems to have been a subtle bug in their PHP installation (PHP, Zend Optimizer and/or Suhosin) which has been fixed with the update. Still, a quite weird thing.
Thanks to all of you!
Best regards
Stefan
Have you tried swapping the tid and type keys? Also how about using a hardcoded variable to check if the problem could be with $GLOBALS['HTTP_RAW_POST_DATA']?
Try the following:
$t1='[{"action":"Setting","method":"toggle","data":["welcome-home"],"type":"rpc","tid":2},{"action":"ContentExtFeFillout","method":"todo","data":[true,0,8,false],"tid":2,"type":"rpc"}]';
print_r(json_decode($t1));