SSL Connection timeout in facebook fql - php

I am using facebook api to get backup of the facebook photos using access_token and fql.
Using fql I got the list of albums of the user
$client = new Facebook(array('appId' => 'xxxx', 'secret' => 'xxxxxx'));
$fql_albums = "SELECT aid,name from album where owner=$user_Id";
$albumId = $client->api(array(
'method' => 'fql.query',
'access_token' => $user_access_token,
'query' => $fql_albums,
));
After getting this list I run a query to get all the photos in the album and then download that album and then moves to the next album.
It only download 2 albums and then gets an error as shown below
( ! ) Fatal error: Uncaught CurlException: 28: SSL connection timeout
thrown in
D:\wamp\www\FrostBox1.0\Facebook\FaceBookConnect\facebook-php-sdk\src\base_facebook.php
on line 759
What could I be doing wrong?

For me, the solution was adding
$opts[CURLOPT_SSLVERSION] = 3;
before
curl_setopt_array($ch, $opts);
in base_facebook.php
Thanks to:
https://developers.facebook.com/bugs/213367445404472/?browse=search_4eeccca164bbe6357503363

open base_facebook.php
find CURLOPT_CONNECTTIMEOUT => 10
change it to CURLOPT_CONNECTTIMEOUT => 30
That's it!

I solved it by adding:
CURLOPT_SSLVERSION => 3,
after the line:
CURLOPT_USERAGENT => 'facebook-php-3.1',
at - base_facebook.php
(it will make curl to use SSLv3)

Related

Connecting to a SOAP service with 2 way SSL

Basically, I am trying to connect to a SOAP service with 2 way SSL (HTTP client certificate authentication).
I am using PHP SoapClient for this within Laravel.
This is what I have, and it allows me to connect and returns the expected response. So the method is basically correct and the certificate is fine etc. It's just I am having trouble with what I guess is the 2 way SSL part.
$client = new \SoapClient('localwsdlfile.wsdl', array(
'local_cert' => 'localcert.pem',
'passphrase' => 'passphrase',
// 'location' => 'https://wsmurl/login/' // Uncomment to login
));
$response = $client->Get(array(
"AccessKey" => "accesskey",
"ProductID" => "SOMEPRODUCT",
"Scope" => "SOMESCOPE",
"Parameters" => array('Param' => array('_' => 'DATATOLOOKUP', 'id'=>'MOREDATATOLOOKUP'))
));
print_r($response);
The only problem is (obviously because I'm doing something wrong), is I need to add the line 'location' => 'https://wsmurl/login/' the first time I try to connect, otherwise I get an error "SoapFault Login Required"
I then remove the line 'location' => 'https://wsmurl/login/', otherwise, I get an error "SoapFault looks like we got no XML document".
The service provider has a 600 second timeout, where I don't have to "login" again for upto 600 seconds.
After removing this line 'location' => 'https://wsmurl/login/', then it works as expected. Obviously, I can't manually add and remove this line, and I guess I am not doing this correctly.
Can someone tell me a better way to do this please?
Thanks,
Because the location for the login and localwsdlfile.wsdl is different, I could not do it with one call. So we created a function using curl to login and if login is successful it will proceed to the soapclient. Thanks to Brian from freelancer for his assistance here.
$client = new SoapClient('wsdl/VocusSchemas/localwsdlfile.wsdl', array(
'trace' => 1,
'exception' => true
));
try {
$response = $client->Get(array(
// "AccessKey" => "MADAITABNSAATOT1",
"AccessKey" => "accesskey",
"ProductID" => "SOMEPRODUCT",
"Scope" => "SOMESCOPE",
"Parameters" => array('Param' => array('_' => 'DATATOLOOKUP', 'id' => 'MOREDATATOLOOKUP'))
));

What is 410 error status in Twitter API?

I have been trying to make an API to retweet using status id, but I got a 410 status error. I searched how to make a retweet and I found the following code, but I face the mentioned error:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require 'tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $consumerKey,
'consumer_secret' => $consumerSecret,
'user_token' => $oAuthToken,
'user_secret' => $oAuthSecret,
'curl_timeout' => 60,
'curl_ssl_verifypeer' => 0
));
$code = $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/retweet/'),
array('id' => '505041593686974464' ));
echo $code;
?>
How can I retweet in Twitter using the tmhOAuth.php class?
Note: I already created an app to post text and images to my Twitter using the tmhOAuth.php class.
From dev.twitter.com:
This resource is gone. Used to indicate that an API endpoint has been
turned off. For example: “The Twitter REST API v1 will soon stop
functioning. Please migrate to API v1.1.”

I'm getting an X509 error with Amazon AWS PHP SDK

Just wondering if anyone knows why Amazon's AWS would be telling me "The X509 Certificate you provided does not exist in our records."
Here's the code I'm using...
$sqs = new AmazonSQS();
$queue_url = 'my_url';
$options = array(
'MaxNumberOfMessages' => 10,
);
$resp = $sqs->receive_message($queue_url, $options);
print_r($resp);
Here's the response I get...
[Type] => Sender
[Code] => InvalidClientTokenId
[Message] => The X509 Certificate you provided does not exist in our records.
[Detail] => CFSimpleXML Object
Here's the CFCredentials array I'm using inside config.inc.php...
'#default' => array(
'key' => 'my-key',
'secret' => 'my-secret',
'default_cache_config' => 'cache',
'certificate_authority' => FALSE
)
In order to use Amazon SQS, you have to specifically sign up for Amazon SQS ; it looks like you are not sign-up. You can do it by visiting this page and clicking the button labeled "Sign up for Amazon SQS".
The reason I was getting this error was because I am using MAMP PRO which doesn't have CURL installed with SSL. Only CURL.
So to get around this so I could test from my local machine was the below code. Note the "#" on the second line. I used this to suppress the warning that is given out by disable_ssl() method.
$s3 = new AmazonS3();
#$s3->disable_ssl();

Error 102 when connect to FB API

I am seeing this error message when I connect to fb
Fatal error: Uncaught Exception: 102:
parameters uid or session key required thrown in C:\Online\lib\fb\base_facebook.php
on line 708
May I know what is the problem? I have verified the appID and Secret Key too. Thank you.
Here is my code in php
$facebook = new Facebook(array('appId' => FB_ID, 'secret' => FB_SCRT, 'cookie' => true,));
$user = $facebook->getUser();
$api_call = array(
'method' => 'users.hasAppPermission',
'uid' => $user,
'ext_perm' => 'publish_stream'
);
$users_hasapppermission = $facebook->api($api_call);
I am trying to have the user's permission to publish to FB stream

Some of the aliases you requested do not exist: facebook graph api, photo to album

I am using facebook graph api to upload photos to existing album in my account.
Here is my code how i am doing.
$fb = new Facebook(array(
'appId' => 'xxxxxxxxx',
'secret' => 'xxxxxxxxx',
'cookie' => 'true'
));
$fb->setFileUploadSupport(true);
$imagePath='C:\\wamp\\www\\photo\\photo.jpg';
$args = array('message' => 'photo caption is...');
$args['image'] = $imagePath;
$data = $fb->api('/'. '5463871911515666183' . '/photos?access_token='. $user_access_token, 'POST', $args);
print_r($data);
when i execute this it shows an error
Fatal error: Uncaught OAuthException: (#803) Some of the aliases you requested do not exist: 5463871911515666183 thrown in C:\wamp\www\photo\facebook-php-sdk\src\base_facebook.php on line 970
The Problem has been solved , i was fetching album IDs using FQL, in which id of an album is represented as 'aid', While in the GRAPH API album id is represented as 'id' while uploading image to an album i am using Graph API, the same object in the FQL and Graph is represented in different.
In the FQL , object_id is equavlent to the Graph API id.

Categories