5 Replies - 575 Views - Last Post: 15 September 2017 - 08:44 AM Rate Topic: -----

#1 ikhlas06  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 178
  • Joined: 20-May 16

how to write VB .net rest api to connect to instagram account?

Posted 13 September 2017 - 06:14 AM

I am using VB .net, and created a basic website

How can I use REST API so user can login to your instagram account using my site? This project is just for learning reasons and its on my localhost.

I alway wanted to learn about rest api code but never really understand how to set up the code. I understand the basic of rest api as in what it does and what it is used for.

It might be alot to ask but can some one give me example code of VB.net rest api to connect to your instagram account?

any thing will help becuase I am not even sure which file do I write rest api code. For example do I write in WebService.vb file or .aspx file or .aspx.vb file?

Is This A Good Question/Topic? 0
  • +

Replies To: how to write VB .net rest api to connect to instagram account?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,888
  • Joined: 12-June 08

Re: how to write VB .net rest api to connect to instagram account?

Posted 13 September 2017 - 11:30 AM

Plenty of github and other sites that have this spelled out.

Example:
https://github.com/v...ram-API-Wrapper
https://code.msdn.mi...n-Said-e1d8d388
.. etc
Was This Post Helpful? 1
  • +
  • -

#3 ikhlas06  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 178
  • Joined: 20-May 16

Re: how to write VB .net rest api to connect to instagram account?

Posted 15 September 2017 - 08:19 AM

Thanks, Your 2nd link helps so much.

error: 'This' is not declared. It may be inaccessible due to its protection level.

I have same thing as the tutorial but for some reason I am getting an error




masterpage.master.vb file
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If (Not String.IsNullOrEmpty(Request.QueryString("code"))) Then
                Code = Request.QueryString("code")
                GetDataInstagramToken()
            End If

        End If
    End Sub
	
    Function GetDataInstagramToken()
        Dim json As String = ""

        Try
            Dim parameters As New NameValueCollection
            parameters.Add("client_id", Client_ID)
            parameters.Add("client_secret", ClientSecret)
            parameters.Add("grant_type", "authorization_code")
            parameters.Add("redirect_uri", Redirect_URI)
            parameters.Add("code", Code)

            Dim client As WebClient = New WebClient()
            Dim result = client.UploadValues("https://api.instagram.com/oauth/access_token", "POST", parameters)
            Dim response = System.Text.Encoding.Default.GetString(result)

            'deserializing nested JSON string to object
            Dim jsResult As JObject = JsonConvert.DeserializeObject(response)
            Dim accessToken As String = jsResult("access_token")
            Dim id As Int16 = jsResult("user")("id")

            'This code register id and access token to get on client side
            Page.ClientScript.RegisterStartupScript(this.GetType(), "GetToken", "<script>var instagramaccessid=\"" + @"" + id + "" + " \ "; var instagramaccesstoken=\"" + @"" + accessToken + "" + " \ ";</script>")

        Catch ex As Exception
            
        End Try
    End Function

This post has been edited by ikhlas06: 15 September 2017 - 08:19 AM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,888
  • Joined: 12-June 08

Re: how to write VB .net rest api to connect to instagram account?

Posted 15 September 2017 - 08:22 AM

.. then don't use "this.".
Was This Post Helpful? 0
  • +
  • -

#5 ikhlas06  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 178
  • Joined: 20-May 16

Re: how to write VB .net rest api to connect to instagram account?

Posted 15 September 2017 - 08:26 AM

Already tiered that. I get error: type expected.

Page.ClientScript.RegisterStartupScript(GetType(), "GetToken", "<script>var instagramaccessid=\"" + @"" + id + "" + " \ "; var instagramaccesstoken=\"" + @"" + accessToken + "" + " \ ";</script>")

This post has been edited by ikhlas06: 15 September 2017 - 08:26 AM

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,888
  • Joined: 12-June 08

Re: how to write VB .net rest api to connect to instagram account?

Posted 15 September 2017 - 08:44 AM

Please copy/paste the entire error message.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1