php curl test url

You can test whether PHP is able to make a CURL connection to a given URL, using the below PHP code:

If you see the result, the CURL call is working.
You can substitute the URL with any URL of your choice, including https URL. But ensure that you have openssl enabled in your PHP extensions. Also, you may need to provide a certificate for making calls.

If you are using XAMPP, add the below lines in your PHP.ini configuration file, depending on your XAMPP path:

And copy the certificate file (ca-bundle.cert) into your XAMPP installation folder.
Download the certificate from here.

FacebookTwitterGoogle+LinkedInEmailShare

wordpress export posts to csv

wp_csv

You can export posts of your wordpress website into a CSV file, by using a simple script like below:

Just create this PHP script in the root folder of your WordPress site and run it from browser. The CSV file containing your posts would be downloaded.
Modify the SQL query for your needs 🙂

FacebookTwitterGoogle+LinkedInEmailShare

wordpress fix ssl certificate problem during upgrade

While upgrading WordPress, you might have come across an issue with SSL Certificate verification, something like:

Download failed.: SSL certificate problem: unable to get local issuer certificate.

The problem is that the WordPress team included the CA certificate check in their 3.7.0 version, and you are using the 3.5.1 version.
As a workaround, you can add the following lines to the wp-config.php file:

You need to add them at the end of the file, after the require_once instruction.
Then, update WordPress from the admin dashboard. When everything is finished and you check that it went fine, remove the lines added in the wp-config.php file. That’s it! Now try upgrading WordPress and it should work !

Reference: Here.

FacebookTwitterGoogle+LinkedInEmailShare

convert rtf to pdf using php

If you are on Windows, and you have COM extension enabled, you can convert RTF (or DOC) files to PDF, with PHP.
Let’s see how to achieve it.
First make sure that you have the required php_com_dotnet extension. In your php.ini, add/uncomment the below line:

Note: You may also required to configure DCOM windows module to use Administrator identity to run the Word application. StackOverflow is the Reference.

FacebookTwitterGoogle+LinkedInEmailShare

Working with PHP OAuth Library

Recently i came across a good PHP library for OAuth. It is Lusitanian PHP Oauth Library.

It is a very robust library for implementing three legged OAuth and supports many OAuth service providers such as Google, Facebook, Twitter, etc.

Authorizing a Twitter user is done as follows:

After the user gets authorized, we get OAuth Token and OAuth Verifier values. Using them, we will fetch an Access Token and make OAuth calls to Twitter as follows:

The library primarily uses session to store the access token, after it is retrieved with the successful user login at the Provider. But if you want to use an existing access token (instead of making the user login each time), you can tweak the library to use the existing access token and store it in the session, for using it immediately (Note that the token should be valid and not be expired).

To store an existing access token in session, you can modify: Service/AbstractService.php:

Once you have a valid access token in session, you can use it to initiate API calls as follows:

Modify the request() function of Service/AbstractService.php, to use access token from php session:

That’s it. Just download the library via Composer, include it in your PHP application and start using OAuth APIs.

FacebookTwitterGoogle+LinkedInEmailShare

Email MPDF pdf attachment using swift mailer

In this post, we try to send a PDF (generated using MPDF PHP library) attachment, using Swift mailer.

Example code:

FacebookTwitterGoogle+LinkedInEmailShare

javascript open popup window full screen

Here i present an easy way to open a popup window as a new tab (full screen) in your browser:

FacebookTwitterGoogle+LinkedInEmailShare

javascript open new tab and close it

It is very easy to open a new tab and close it with javascript. Refer to the code below:

FacebookTwitterGoogle+LinkedInEmailShare

hosting web tutorials