Facebook::Graph Could not fetch access token TLS Support not available - perl

Im' trying to use facebook api with perl module Facebook::Graph
First step, get che code:
my $fb = Facebook::Graph->new(
app_id => 'xxxx',
secret => 'xxxx',
postback => 'http://xxxxx/fb_postback',
);
my $uri = $fb
->authorize
->uri_as_string;
Now I have the code param and I try to get the auth token:
$fb->request_access_token($RETURNED_PARAM_CODE);
The server log this error:
Could not fetch access token: TLS support not available on this system at perl5/site_perl/5.10.0/Facebook/Graph/AccessToken/Response.pm line 26.
Any ideas?

Install Net::SSLeay and AnyEvent::TLS, or better upgrade Facebook::Graph to >= 1.0502.

Related

Ruby gem facebook_ads exception_with_response: 400 Bad Request

I'm trying to query the Facebook Marketing API Insights using the facebook_ads Ruby gem. https://github.com/tophatter/facebook-ruby-ads-sdk
I created an app and have Editor permissions on the relevant pages for my company.
Next, I generated a user access token from this page after selecting ads_management permissions.
Next, I followed the instructions on this page to get a permanent page access token.
With the code below I get this error:
/var/lib/gems/2.3.0/gems/rest-client-/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:223:in exception_with_response': 400 Bad Request (RestClient::BadRequest)
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:103:inreturn!'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:809:in process_result'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:725:inblock in transmit'
from /usr/lib/ruby/2.3.0/net/http.rb:853:in start'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:715:intransmit'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in execute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:inexecute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient.rb:67:in get'
from /var/lib/gems/2.3.0/gems/facebook_ads-0.6.6/lib/facebook_ads/base.rb:15:inget'
from /var/lib/gems/2.3.0/gems/facebook_ads-0.6.6/lib/facebook_ads/ad_account.rb:10:in `all'
I have also tried this code with my temporary user access code but get the same result.
Here is my code
#!/usr/bin/ruby
require 'facebook_ads'
MY_PAGE_PERMANENT_ACCESS_CODE = 'my access code'
APP_SECRET = 'my app secret'
FacebookAds.access_token = MY_PAGE_PERMANENT_ACCESS_CODE
FacebookAds.app_secret = APP_SECRET
accounts = FacebookAds::AdAccount.all
It turns out that I was using the page permanent access token which was out of scope for the API call. I needed to use my temporary user access code.
E, [2019-01-19T00:08:49.366067 #19868] ERROR -- : GET /me/adaccounts
OAuthException / 100: (#100) Tried accessing nonexisting field
(adaccounts) on node type (Page) RestClient::BadRequest: 400 Bad
Request
In the pry console for the gem I ran this command to set the account variable:
pry(main)> account = FacebookAds::AdAccount.find('act_MY_ACCOUNT_ID')
and I get this error:
E, [2019-01-19T00:12:24.760545 #20188] ERROR -- : GET /me/adaccounts
OAuthException / 2635: (#2635) You are calling a deprecated version of
the Ads API. Please update to the latest version: v3.2.
RestClient::BadRequest: 400 Bad Request
So, I ran this command:
pry(main)> FacebookAds.base_uri = 'https://graph.facebook.com/v3.2'
"https://graph.facebook.com/v3.2"
Then pry(main)> account = FacebookAds::AdAccount.find('act_MY_ACCOUNT_ID') again.
Finally, I ran:
pry(main)> account.ad_insights
but the result is an empty array when I know this should not be blank. I'm going to skip the gem and use Ruby net/http to query the API directly.

Perl WWW::Mechanize for HTTPS over proxy

I am trying to scrape a website using WWW::Mechanize module. I have configured the mechanize agent with a proxy URL and setting the proxy credentials using credentials method.
Code snippet :
my $url = 'https://abcde.com';
my $proxy_username = 'abc';
my $proxy_password = 'xyz';
my $proxy_url = 'http://xx.xxx.xxx.xxx:13228';
my $mechanize_agent = new WWW::Mechanize('cookie_jar' => {}, 'noproxy' => 1, 'ssl_opts' => { 'verify_hostname' => 0 });
$mechanize_agent->credentials( $proxy_username, $proxy_password );
$mechanize_agent->proxy(['http', 'https'], $proxy_url);
$mechanize_agent->get($url) or die 'Error in get request of $url: $#';
When URL is a plain HTTP, the script fetches and gives back the result. But when I try to hit HTTPS url I get the error
establishing SSL tunnel failed: 407 Proxy Authentication Required
I credentials are valid and I can view the website using proxy URL in Mozilla browser. Also i need t avoid using call to env_proxy() function since the proxy URL is dynamic. How can I get let my script fetch HTTPS request?
All suggestions are welcome!
thanks in advance.

Uber API issue : Getting error while using this code. SSL certificate self signed certificate in certificate chain

I am new to Uber API, I just started exploring the Uber API's.
I have downloaded the complete Uber API repository from https://github.com/stevenmaguire/uber-php/issues/17
I have downloaded the complete repository using the composer. It shows that all dependencies were downloaded successfully. but when I am using the API, I am getting this error
Blockquote"SSL certificate problem: self signed certificate in certificate chain"
Please help me in this, I have raised this issue 8 days back on the Github no one is replied.
Here is my code
Thanks in Advance.
Rakesh
Here is my code`
<?php
require __DIR__ . '/vendor/autoload.php';
$client = new Stevenmaguire\Uber\Client(array(
'access_token' => '********',
'server_token' => '********',
'use_sandbox' => false, // optional, default false
'version' => 'v1.2', // optional, default 'v1.2'
'locale' => 'en_US', // optional, default 'en_US'
));
$products = $client->getProducts(array(
'latitude' => '41.85582993',
'longitude' => '-87.62730337'
));
var_dump($products);
?>
`

OpenAm With Redmine cannot logout |HTTP Status 400 - Error processing LogoutRequest. Single Logout Response Service location not found

OpenAM as single sign-on in Redmine is working for me, but I can't sign out from Redmine. This is the error I get:
HTTP Status 400 - Error processing LogoutRequest. Single Logout Response Service location not found.
The config file is:
Redmine::OmniAuthSAML::Base.configure do |config|
config.saml = {
:assertion_consumer_service_url => "http://xxxxx/redmine/auth/saml/callback", # The redmine application hostname
:issuer => "Redmine", # The issuer name
:idp_sso_target_url => "http://xxxxxx:8080/openam/SSORedirect/metaAlias/idp1", # SSO login endpoint
:idp_cert_fingerprint => "DE:xxxx", # SSO ssl certificate fingerprint
:name_identifier_format => "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
:signout_url => "http://oxxxx:8080/openam/IDPSloPOST/metaAlias/idp1",
:idp_slo_target_url => "http://xxxxxx:8080/openam/IDPSloRedirect/metaAlias/idp1",
:name_identifier_value => "mail", # Which redmine field is used as name_identifier_value for SAML logout
:attribute_mapping => {
# How will we map attributes from SSO to redmine attributes
:login => 'extra.raw_info.username',
:firstname => 'extra.raw_info.first_name',
:lastname => 'extra.raw_info.last_name',
:mail => 'extra.raw_info.email'
}
Please help me fix it.
Your ruby app protected by omniauth is not defining any Single Logout Service URL so if there is any SLO flow, the IdP doesn't know where to send the LogoutRequest / LogoutResponse.
ruby-saml defines it as 'assertion_consumer_logout_service_url' or 'single_logout_service_url', and here is how the ruby-saml toolkit process a SLO
Sadly omniauth does not support yet this feature, but there is a PR that you can apply.

PayPal Rest API Curl SSL : unable to get local issuer certificate

I am working on PayPal Express checkout restapi service.
I complated successfully at sandbox mode but when trying go online curl returns "unable to get local issuer certificate" error. At sandbox i dont get this error.
What i tried!
I tried bind cert file (Latest one from mozilla) in php.ini and curl parameter but nothing change.
Currently my code like this
//Building our NVP string
$request = http_build_query($requestParams + $params);
//cURL settings
$curlOptions = array (
CURLOPT_URL => https://api-3t.paypal.com/nvp,
CURLOPT_VERBOSE => 1,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CAINFO =>'certs/cacert.pem', //CA cert file
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $request
);
$ch = curl_init();
curl_setopt_array($ch,$curlOptions);
Where i am failing ?
Note: I already got API Signature for LIVE from
https://www.paypal.com/us/cgi-bin/webscr?cmd=_get-api-signature
I fixed problem.
Mozilla's certs is failing on live edition.
When i used Facebook's cert it fixed.