Announcement

Collapse
No announcement yet.

HTTP profile - Twitter API brackets

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    HTTP profile - Twitter API brackets

    Hi All,
    I am just starting out with this plugin, looks very useful ! I'm pulling back some JSON from the twitter API and its received (can be seen in the BIG5 debug log) with square brackets enclosing all of it which seems to break the JSON expressions, eg :

    Code:
    [{
        "trends": [{
                "name": "#Beloved_Spring_Xiumin",
                "url": "http://twitter.com/search?q=%23Beloved_Spring_Xiumin",
                "promoted_content": null,
                "query": "%23Beloved_Spring_Xiumin",
                "tweet_volume": 403459
            },
            {
                "name": "#HAPPYXIUMINDAY",
                "url": "http://twitter.com/search?q=%23HAPPYXIUMINDAY",
                "promoted_content": null,
                "query": "%23HAPPYXIUMINDAY",
                "tweet_volume": 424678
            },
            {
                "name": "#ام_العمري_تنشادكم_بالله",
                "url": "http://twitter.com/search?q=%23%D8%A7%D9%85_%D8%A7%D9%84%D8%B9%D9%85%D8%B1%D9%8A_%D8%AA%D9%86%D8%B4%D8%A7%D8%AF%D9%83%D9%85_%D8%A8%D8%A7%D9%84%D9%84%D9%87",
                "promoted_content": null,
                "query": "%23%D8%A7%D9%85_%D8%A7%D9%84%D8%B9%D9%85%D8%B1%D9%8A_%D8%AA%D9%86%D8%B4%D8%A7%D8%AF%D9%83%D9%85_%D8%A8%D8%A7%D9%84%D9%84%D9%87",
                "tweet_volume": null
            }
        ],
        "as_of": "2020-03-25T18:04:12Z",
        "created_at": "2020-03-25T18:01:32Z",
        "locations": [{
            "name": "Worldwide",
            "woeid": 1
        }]
    }]

    When using ${ JSON(input, "trends[0].name") } in the expression sandbox it pulls back back the correct string when the "[" and "]" brackets are removed, but returns blank when they are left in place.

    Does anyone know what the correct way of stripping these brackets "[" and "]" at the beginning and end of the JSON response, or maybe receiving this data without the brackets in the first place ?


    Thanks,
    Mike

    #2
    Big5 can handle that. See below.

    Comment


      #3
      Group tags [ and ] are valid JSON syntax and very common.

      Comment


        #4
        mikesnook

        ​​​​​​​Problem solved.

        Use this RegEx please

        ${ JSON(input, "[0].trends[0].name") }

        Comment


          #5
          Originally posted by risquare View Post
          mikesnook

          Problem solved.

          Use this RegEx please

          ${ JSON(input, "[0].trends[0].name") }
          Awesome thank you, worked perfectly!

          Comment


            #6
            mikesnook I am quite the newbie and just starting off with this plugin and would like to extract new tweets from a few different users and populate the strings in HS4 devices. Could you please show me how you setup your profile? I am not able to access Twitter anonymously anymore due to Elon's recent change but I do not have any problem using my logon credentials.

            I am just confused if I have to use the API with Twitter Developer login credentials or a regular user?

            Thanks for your help!

            Comment


              #7
              Originally posted by will40 View Post
              mikesnook I am quite the newbie and just starting off with this plugin and would like to extract new tweets from a few different users and populate the strings in HS4 devices. Could you please show me how you setup your profile? I am not able to access Twitter anonymously anymore due to Elon's recent change but I do not have any problem using my logon credentials.

              I am just confused if I have to use the API with Twitter Developer login credentials or a regular user?

              Thanks for your help!
              Hi, Sorry I no longer have that profile, I would guess I was using a regular user account though. Good luck!

              Comment


                #8
                Thanks for quick reply.

                Does anyone currently use BIG6 with the Twitter API? I have about 5 feeds I would like to monitor. I don't know where to start and I thought this might be the best way.

                Thanks

                Comment


                  #9
                  Please post to Big6 forum and provide as much details as possible I’ll try to help.

                  Comment


                    #10
                    Thanks for the offer risquare but after some lengthy reading today it seems Twitter's official API is completely useless at the free tier. The API next tier is $100 a month. It's not worth it for what I wanted to do. I'll keep my eyes open to see if this change is temporary or permanent.

                    Comment

                    Working...
                    X