Create Blogs Shopify API

The tutorial explains how to create blogs shopify API. Using shopify api it is easy to create blogs externally.The API is used to transfer blogs from one store to another.

Establish Shopify Connection

As the first step we need to establish the connection and build the API as shown below

Export_Import_Blogs_Shopify_API

Create Blogs Shopify API

The following code create the new blog post as shown below.

Click here for detailed explanation and download the full code.

create-blogs-shopify-api
Export Import blogs Shopify api full code.

public function postBlogs() {
    
    $api = 'blogs/2234777628/articles.json';
    $baseUrl = $this->objauth->getApiUrl().$api;
    $blogs = $this->blogData();
    $response = $this->objaccess->postContents( $blogs, $baseUrl );
    return $response;
    
}

public function blogData() {
    
    $blogDataArr = array(
        'article' =>array( 
            'title' => 'Blog Created',
            'body_html' =>'Test Blog Content',
            'tags' => 'Blog Created',
            'published_at' => date('Y-m-d H:i:s'),
            'author' => 'barbflies Admin'
        )
    );
    
    return $blogDataArr;   
}

Share this Tutorial