Chin-Hock Tan

Chin-Hock Tan

I am a full time internet retailer, selling physical products through my own websites and various internet marketplaces. I write PHP web bots and screen scraper scripts during my free time for email marketing to increase web traffic, scraping products from one website to another to minimize manual entries, aggregate content for new websites etc.

I am available for hire as freelance PHP coder on web bots, screen scraper and data mining. I quote fixed price for your project if the detail of requirements are clearly outlined. 

I also help customers to build and host Joomla based business/content/blogging website, shopping cart with Virtuemart, Presta Shop, Open Cart, EC Shop, EC Mall etc. First year hosting is free.

I accept payment via Paypal. If you would like to contact me, please write to freeman [a] php8legs.com. TQ.

 

我是一名全职的网上零售商,通过自己的网站和不同的交易平台售卖实物商品。我在空闲时间写PHP机器人和网络资料提取脚本,并用于电子邮件营销以增加网站流量,从一个网站提取产品信息到另一个网站以减少手工输入,为新网站聚合内容等。

您可聘请我编码PHP机器人,网络资料提取脚本及数据挖掘。如果您详细明确阐述您的要求,我会报您一个固定的价格。

我也为客户用Joomla建立业务/内容/博客相关网站,用Virtuemart, Presta Shop, Open Cart, EC Shop, EC Mall等创建购物网站。我提供网页寄存,第一年是免费的。

我接受通过PayPal付款。如果您想联系我,请写信给“freeman [a] php8legs.com”。 谢谢。

Website URL: http://php8legs.com

Pinterest bot - How to auto-login with php-webdriver + Selenium

pinterest auto login

Pinterest is one of the most popular social media to upload beautiful photos and website links. In the past, I used php-pinterest-bot from Seregazhuk to create pinterest boards and auto post items to Pinterest. This is a great script that covered many aspects of Pinterest automation, including auto like, auto follow etc. Another great script with excellent support is py3-pinterest bot in Python 3 from Bstoilov. However, Pinterest has integrated with Google Recaptcha around Nov/Dec 2020. Both scripts are not able to login as before. Sadly, php-pinterest-bot is not supported since. As for py3-pinterest, it has changed login method by calling Selenium, then the rest of the code still as normal. 

To continue with Pinterest automation, I have changed my script to use php-webdriver and Selenium to auto login and auto post (single image, multiple images and video) to Pinterest. In this article, let's discuss how to login Pinterest with cookies.

How to avoid Selenium webdriver from being detected as bot or web spider

selenium as bot

 

Before we start to use php-webdrive and Selenium for web scraping and social media auto posting, we need to do some settings in code or file modifications to avoid our script from being detected as web bot or spider. I have listed some ways to hide our automation using Selenium. The methods can be used for any programming languages as well. Please note that this is not a complete list and from time to time web servers companies can find new methods to detect and block our Selenium automation. Anyway, we just have to factor in all known methods in our scripts to reduce chances of detection.

1. Remove browser control flag

2. Remove signature in javascript

3. Set User-Agent

4. Avoid using headless browser

5. Use maximum resolution

6. Follow page flow

7. Use proxy or VPN

8. Insert random delay

9. Use cookies to login

How to install php-webdriver + Selenium for screen scrapping and auto-post

phpwebdriver

Today I look at the content of php8legs.com and realize that I have not writing in website for more than 4 years already. It was a busy four years. As Malaysia is implementing MCO (Movement Control Order) due to wide spread of Covid-19 virus, I have the chance to take sometime to discuss the topics of my interest - web scraping and auto posting.

In the articles, I want to discuss about more advanced scraping techniques such as scraping website with infinite scroll, as well as using webdriver to auto login social media websites and perform auto posting. All this can be done using Selenium. There are already so many articles on Selenium + webdrivers in Python/Java/Ruby etc. So I want to write this topic using PHP. To run Selenium with PHP under Windows 10 environment, assuming you already have XAMPP installed (with PHP 7 or above), here are the software packages required: 

1. Java - installation

2. Composer - installation

3. php-webdriver from github.com  - installation

4. Selenium Standalone Server - download

5. Chromedriver - download

If you already have Java and composer installed earlier, then just perform installation at step 3 and download packages at step 4 and 5.

How to auto-follow, auto-comment and auto-like a post on Instagram Page with PHP/cURL (2)

instagram

In the last article, I use a script to autopost image to Instagram. In this article, here is a script to auto-follow, auto-like and auto-comment a batch of Instagram posting based on specific tag search results.
You need to set a group of targeted tag (or keywords). The script will randomly pick up one tag each time and search for most recent postings with this tag. To avoid being detected by Instagram, the script will only auto-follow, auto-like and auto-comment not more than 40 (you can set your number in the script) postings each batch.
Owners of the posting with high like count (example 300 like count) most likely NOT interested to know who come to like their postings. So to get the best results from the script, the code will avoid postings that already have high like count and only like those postings with like count less than 20 (you can set your number in the script). This is to get the attention of the posting owners so that they can take next cause of action, such as follow you back or say thank you to your comment. As such, your followers will increase. I will show you the results in the last part of this article.
If you are already following a user, the script will not follow that user again. It will then only like the posting of that user. This is to avoid the same user sees repeating comment from us.

So if you like what the script can do for you, here is the code!

How to auto publish post on Instagram Page with PHP/cURL and without using Instagram API (1)

Instagram is one of the most difficult apps for developers to schedule auto posting without using API. Instagram is specifically designed to support uploads from mobile phones only. Instagram team only gives whitelist access to limited  third-party apps for automatic posting on a case by case basis. Another reason is Instagram team want to fight spam and low quality photos.

I was looking for a way to auto posting from website to Instagram page using PHP/cURL without using API since last two years. Lately I found two websites that are discussing about this topic.

Posting a Photo to Instagram Without a Phone

instagram-photo-upload-batuhanorg.php

Initially I was not able to make the coding working immediately after download the source files due to several issues such as PHP 5.5 vs 5.6 issue as well as new signature key from instagram app. In this tutorial, I will show you a working draft to auto post single photo to Instagram page using PHP/cURL. I am take no responsibility if your account banned by Instagram. :)

New and Updated! Facebook Remote Status Update with PHP/cURL Bot

  • 02 September 2015 |
  • Published in Facebook
Mobile Facebook Login Page

I published "Facebook Remote Status Update with PHP/cURL Bot" in Feb 4 2014. The script was working well until early this year. I received comments and emails that script no longer working and requested an update. So here I try to find out any changes to Facebook login form and status update.

In summary, the login portion still working fine. However, Facebook has converted status update form into unicode format as well as one of the key value in the status update form. In fact, just need to change one line of my old script to continue our facebook autologin and status update.

How to auto publish post on Facebook Fan Page as admin using Facebook PHP SDK V4 Graph API v2.2 (4) - Integrate with Opencart

  • 05 January 2015 |
  • Published in Facebook

In the last part of this article, I am going to show you a simple example how to integrate the Facebook PHP SDK and Graph API into Opencart and auto publish products to Facebook Page. The example is a simplified version of my own script. You might want to modify this script on your shopping cart.

This script will randomly pick one of the published product from Opencart MySQL database and use the code in previous article for auto posting. By running the script under crob tab four times a day, for example, there are four product published everyday. 

This script is tested on Opencart 1.5.6.4.

Here is the sample code to do that:

How to auto publish post on Facebook Fan Page as admin using Facebook PHP SDK V4 Graph API v2.2 (3) - Single Product Manual Posting

  • 04 January 2015 |
  • Published in Facebook

Facebook Auto Posting

After setting up Facebook App and getting a permanent Page Access Token, we now write a simple code to post a product to Facebook page. We need to download facebook PHP SDK v4 from github. You can get the file from here. Unzip the file and go to directory "Facebook". You can upload this directory to your server. 

Since v4.0.9, Facebook PHP SDK v4 come with autoloader, we don't have to use Composer (Dependency Manager for PHP). For the file downloaded just now, there is a file call "autoloader.php" before "src" directory. In my case, I moved this file into Facebook directory as well. 

Here is the code:

How to auto publish post on Facebook Fan Page as admin using Facebook PHP SDK V4 Graph API v2.2 (2) - Get Permanent Page Access Token

  • 03 January 2015 |
  • Published in Facebook

Graph API Explorer

There are various types of access token for facebook app. The best article that explains them is How to handle access tokens with Facebook SDK v4.0 by Sammy Kaye. To post article / item / product from our own website to facebook fan page, we need to use Page Access Token.

The initial token can be obtained from Facebook Graph API tool. However, that is just a short-lived access token, which will expire in an hour or two after generation. We need to made a Graph API call to get a long-lived access token, which has two months expiry date. Lastly, get a permanent access token, which will never expire and can be used in our daily script.

We can test our script using short-lived access token, but then you have to regenerate another token after expiration. So we should directly get permanent access token before writing our script.

How to auto publish post on Facebook Fan Page as admin using Facebook PHP SDK V4 Graph API v2.2 (1) - Create Facebook App

  • 31 December 2014 |
  • Published in Facebook

Facebook Developers

I have a ecommerce webstore using OpenCart with around 2000 products. I have created twitter, goolge+, pinterest and facebook page for this website. With Google moving towards semantic search, all these social signals are increasingly important. Everyday, I have to select one or two products and post on these social media websites. I don't like to do this manually and need to find ways to let a script doing the posting. For facebook page, I can use the APIs for daily auto posting. 

When I search for "Facebook PHP SDK for auto posting", there are lots of confusing results, mainly due to code written in different Facebook SDK versions. The documentation from Facebook developers website also quite difficult to understand. However, after reading articles from many websites, trial and error with example codes, finally I am able to do auto posting with Facebook PHP SDK v4 and Graph API v2.2.

Here's my expectations:

1) I want to auto post to Facebook Fan Page as admin.

2) No Login with Facebook required.

3) I want to post product title, product url, and product image, just like normal posting.

4) With 2000++ product listing and still increasing, I want able to auto post three to five items per day. It will take more that one year to post all products from my website. 

In part 1 of this article, I will describe how I set up facebook app. In the next article, I will describe the code used to auto post single item to facebook page.

Subscribe to this RSS feed