<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Get Growth Tools &#8211; Chatbot Dojo</title>
	<atom:link href="https://v3.chatbotdojo.com/topic-category/get-growth-tools/feed/" rel="self" type="application/rss+xml" />
	<link>https://v3.chatbotdojo.com</link>
	<description></description>
	<lastBuildDate>Tue, 25 Aug 2020 11:43:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.2</generator>

<image>
	<url>https://v3.chatbotdojo.com/wp-content/uploads/2020/07/favicon-56x56.png</url>
	<title>Get Growth Tools &#8211; Chatbot Dojo</title>
	<link>https://v3.chatbotdojo.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to retrieve all Growth Tools with /fb/page/getGrowthTools</title>
		<link>https://v3.chatbotdojo.com/topic/how-to-retrieve-all-growth-tools-fb-page-getgrowthtools/</link>
		
		<dc:creator><![CDATA[ninjawarrior]]></dc:creator>
		<pubDate>Tue, 25 Aug 2020 11:42:47 +0000</pubDate>
				<guid isPermaLink="false">https://v3.chatbotdojo.com/?post_type=sfwd-topic&#038;p=25196</guid>

					<description><![CDATA[The curl command as displayed on the ManyChat API Swagger is: The purpose of this API call is to get all created Growth Tools in your ManyChat account. Why would you need this? To be honest, I do not see a lot of use cases for this feature. Maybe there&#8217;s some way it can be &#8230;<p class="read-more"> <a class="" href="https://v3.chatbotdojo.com/topic/how-to-retrieve-all-growth-tools-fb-page-getgrowthtools/"> <span class="screen-reader-text">How to retrieve all Growth Tools with /fb/page/getGrowthTools</span> Read More &#187;</a></p>]]></description>
										<content:encoded><![CDATA[
<p>The curl command as displayed on the ManyChat API Swagger is:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="php" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">curl -X GET "https://api.manychat.com/fb/page/getGrowthTools" -H "accept: application/json"</pre>



<p>The purpose of this API call is to get all created Growth Tools in your ManyChat account.</p>



<h2>Why would you need this?</h2>



<p>To be honest, I do not see a lot of use cases for this feature. Maybe there&#8217;s some way it can be helpful to you, but for us: not so much :-).</p>



<p>By using this API you can get a list of growth tools, but since it is only giving you the <strong>ID</strong>, <strong>Name </strong>and <strong>Type </strong>of the tools, there&#8217;s not much other than reporting what is created.</p>



<p>This is the default response on a successful request. It looks similar to the one for creating Tags.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
  "status": "success",
  "data": [
    {
      "id": 0,
      "name": "string",
      "type": "string"
    }
  ]
}</pre>



<h2>So how do we use this in our own system?</h2>



<blockquote class="wp-block-quote"><p>We assume you started in the First chapter of this course, and are now aware of the creation of the class file and the config file.<br>Those files are being used in ALL scripts we explain in the course. If you missed it, <a href="https://v3.chatbotdojo.com/topic/fb-page-getinfo/">go here</a> and read it.</p></blockquote>



<p>First we will add a new function to our class file in classes/manychat.class.php.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="241" data-enlighter-title="" data-enlighter-group="">    /**
     * 
     * @param type $mc_api
     * @return type
     */
    function getGrowthTools($mc_api)
    {

        $ch            = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://api.manychat.com/fb/page/getGrowthTools");
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $headers       = [
            'Authorization: Bearer ' . preg_replace("/^(\w+\s+)/", "", $mc_api),
            'Content-Type: application/json',
            'Accept: application/json'
        ];
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $server_output = curl_exec($ch);
        curl_close($ch);

        $json_obj  = json_decode($server_output);
        $good_call = $json_obj->status;

        if ($good_call == "success") {
            usort($json_obj->data, function($a, $b) {
                // Sort by GT Type
                return strcmp($a->type, $b->type);
            });

            $growthTools = $json_obj->data;

            return $growthTools;
        }
    }</pre>



<p>After we created the new function, we will create a new PHP file and call it <strong><em>page_get_growthtools.php</em></strong>. Here&#8217;s the start of our new PHP file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php

/*
 * Load the ManyChat Config File
 */
require_once './config.inc.php';

/*
 * Get the Growth Tools for your page
 */

// add functions here</pre>



<p>We will add a call to the function from the class file now, then create a loop to display all the information from the JSON Object that was returned by the class method (function).</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="12" data-enlighter-title="" data-enlighter-group="">$page_growthTools = $mc->getGrowthTools($mc_api);

foreach ($page_growthTools AS $growthTools) {
    echo $growthTools->id . "&lt;br />";
    echo $growthTools->name . "&lt;br />";
    echo $growthTools->type . "&lt;br />&lt;br />";
}</pre>



<p>Now, when we run the file (<strong><em><strong><em>page_get_growthtools</em></strong></em>.<em>php</em></strong>) in our browser, we should see the following result:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="" data-enlighter-highlight="3,4,6" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">...
2921004
Loyalty Card Redeem Scanner
messenger_code

2920999
Loyalty Card + Get Wi-Fi
messenger_code

2170970
180606 - Store Owner Stats Viewer 3
messenger_code
...</pre>



<p>That&#8217;s great! We successfully listed all the growth tools in the ManyChat system, all in our own environment! </p>



<p>We now have a fully functional script that can list all those growth tools, all from our own localhost, or server. Eternal bragging rights can be earned here if you tell me at least 1 useful use case for this , promised!</p>



<p>The full PHP script now looks like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php

/*
 * Load the ManyChat Config File
 */
require_once './config.inc.php';

/*
 * Get the Growth Tools for your page
 */

$page_growthTools = $mc->getGrowthTools($mc_api);

foreach ($page_growthTools AS $growthTools) {
    echo $growthTools->id . "&lt;br />";
    echo $growthTools->name . "&lt;br />";
    echo $growthTools->type . "&lt;br />&lt;br />";
}
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
