Fieldtype, Module

Archived
Forum
(read-only)

CE Tweet

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Causing Effect

     

CE Tweet behind a VPN Network

Support (Resolved)

o4
o4

Hi aaron,

I had to transfer a site behind a VPN network, and now CE tweet and other add-ons that connect to the outer world have stopped working.

I already had contact with the instagram picpuller add-on dev. and he told me that I would need a proxie server to make it work again:
http://devot-ee.com/add-ons/support/pic-puller-for-instagram/viewthread/11422#39644

did you have this situation already?
would you be able to help me with this?
I don’t mind if I have to pay you for doing it since it’s outside the usual support scheme. I just want it to work, and I think you’re the best man for the job :)

please let me know what you think.
cheers
stefan

Causing Effect - Aaron Waldon
# 1
Developer
Causing Effect - Aaron Waldon

Hi o4!

This would be difficult for me to test, since I’m not running anything behind a VPN. Since you already know which cURL options are working for the other add-on you’re adding VPN support to, you should be able to add those same options where needed to the CE Tweet classes.

You’ll probably want to do a search for ‘curl_init’ in the CE Tweet files, and look were the other ‘curl_setopt’ options are being set. Add the cURL options that you need where necessary, and that may resolve the issue.

Please let me know how that goes. :)

o4
# 2
o4

hi, so it was THAT easy!

so I’ve changed this “third_party/ce_tweet/library/EpiTwitter.php” file:

private function request_basic$method$endpoint$params null$username null$password null )
 
{
  $url 
$this->getApiUrl$endpoint );
  if ( 
$method === 'GET' )
  
{
   $url 
.= is_null$params ) ? '' '?' http_build_query$params'''&' );
  
}
  $ch 
curl_init$url );
  
curl_setopt$chCURLOPT_HTTPHEADER, array( 'Expect:' ) );
  
curl_setopt$chCURLOPT_RETURNTRANSFERtrue );
  
curl_setopt$chCURLOPT_TIMEOUT$this->requestTimeout );
  
curl_setopt$chCURLOPT_CUSTOMREQUEST$method );

// NEW LINES START HERE
 
curl_setopt($chCURLOPT_PROXYTYPECURLPROXY_HTTP);
 
// CURLOPT_PROXY should be set to the IP address and port of the proxy you are using instead of 12.345.67.89:12345
 
curl_setopt($chCURLOPT_PROXY'XXX myproxie XXX');
 
// Change 'username' to your username and 'password' to your password. If you don't have a username/password, your proxy might not require it and you can comment out the following line
 // curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password');
// NEW LINES END HERE

  
if ( $method === 'POST' && $params !== null )
  
{
   
if ( $this->isMultipart$params ) )
   
{
    curl_setopt
$chCURLOPT_POSTFIELDS$params );
   
}
   
else
   
{
    curl_setopt
$chCURLOPT_POSTFIELDS$this->buildHttpQueryRaw$params ) );
   
}
  }
  
if ( !empty( $username ) && !empty( $password ) )
  
{
   curl_setopt
$chCURLOPT_USERPWD"{$username}:{$password});
  
}

  $resp 
= new EpiTwitterJsonEpiCurl::getInstance()->addCurl$ch ), $this->debug );
  if ( !
$this->isAsynchronous )
  
{
   $resp
->response;
  
}

  
return $resp;
 

and this in the “third_party/ce_tweet/library/EpiAuth.php”:

protected function curlInit$url )
 
{
  $ch 
curl_init$url );
  
curl_setopt$chCURLOPT_RETURNTRANSFERtrue );
  
curl_setopt$chCURLOPT_HTTPHEADER$this->headers );
  
curl_setopt$chCURLOPT_TIMEOUT$this->requestTimeout );
  
curl_setopt$chCURLOPT_CONNECTTIMEOUT$this->connectionTimeout );
  
curl_setopt$chCURLOPT_ENCODING'' );
  if ( 
$this->followLocation && ! ini_get'safe_mode' ) && ! ini_get'open_basedir' ) ) //safe_mode and open_basedir conditionals added by Aaron Waldon on 04-16-2012 to prevent errors on some hosts (like Engine Hosting)
  
{
   curl_setopt
$chCURLOPT_FOLLOWLOCATIONtrue );
  
}
  
/* Removed on 01/18/2013 by Aaron Waldon, since it was causing issues for several people
  if ( isset( $_SERVER [ 'SERVER_ADDR' ] ) && ! empty( $_SERVER[ 'SERVER_ADDR' ] ) && $_SERVER[ 'SERVER_ADDR' ] != '127.0.0.1' )
  {
   curl_setopt( $ch, CURLOPT_INTERFACE, $_SERVER [ 'SERVER_ADDR' ] );
  }
  */

// NEW LINES START HERE
 
curl_setopt($chCURLOPT_PROXYTYPECURLPROXY_HTTP);
 
// CURLOPT_PROXY should be set to the IP address and port of the proxy you are using instead of 12.345.67.89:12345
 
curl_setopt($chCURLOPT_PROXY'XXX myproxie XXX');
 
// Change 'username' to your username and 'password' to your password. If you don't have a username/password, your proxy might not require it and you can comment out the following line
 // curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password');
// NEW LINES END HERE

  //if the certificate exists then use it, else bypass ssl checks
  
if ( file_exists$cert dirname__FILE__ ) . DIRECTORY_SEPARATOR 'ca-bundle.crt' ) )
  
{
   curl_setopt
$chCURLOPT_CAINFO$cert );
   
curl_setopt$chCURLOPT_SSL_VERIFYPEERtrue );
   
curl_setopt$chCURLOPT_SSL_VERIFYHOST);
  
}
  
else
  
{
   curl_setopt
$chCURLOPT_SSL_VERIFYPEERfalse );
   
curl_setopt$chCURLOPT_SSL_VERIFYHOSTfalse );
  
}
  
return $ch;
 

and it seems to work! OMG!

but I am not sure about the position of these new lines.
do you think they are ok there?

btw: it’s ce_tweet 1.3.6 and ExpressionEngine 2.6.1

I guess I’ll have to do the same with ce_image?

cheers and thanks a lot for pointing me into the right direction!
stefan

Causing Effect - Aaron Waldon
# 3
Developer
Causing Effect - Aaron Waldon

Nice. :) It looks fine. Glad it’s working.