title: Unexpected character json error in r
body: <p>I'm getting the following error message for this code intended to read Instagram posts into r.  Other code is successfully reading in the first 20 posts, but Instagram wants you to request the "next_url" to get additional blocks of posts.  I looked at similar answers to this error, but can't find the typo in my code.  Did wonder if it could be something coming from the API that needs to be adjusted.  I'm new to R and hope I explained this appropriately.  I would greatly appreciate any assistance.</p>
  
  <blockquote>
  <pre><code>Error in fromJSON(getURL(paste(next_url, token, sep = "")), unexpected.escape = "keep") : 
    unexpected character: p
  In addition: Warning message:
  In fromJSON(getURL(paste(next_url, token, sep = "")), unexpected.escape = "keep") :
    unexpected escaped character '\ ' at pos 26. Keeping value.
  </code></pre>
  </blockquote>
  
  <pre><code>  username &lt;- "XXXX"
      if(grepl(received_profile$username,username))
    {
      user_id &lt;- received_profile$id
      media &lt;- fromJSON(getURL(paste(next_url,token,sep="")),unexpected.escape = "keep")
      df1 = data.frame(no = 1:length(media$data))
  
      for(i in 1:length(media$data))
      {
        #comments
        df1$comments[i] &lt;-media$data[[i]]$comments$count
  
        #likes:
        df1$likes[i] &lt;- media$data[[i]]$likes$count
  
        #date
        df1$date[i] &lt;- toString(as.POSIXct(as.numeric(media$data[[i]]$created_time), origin="1970-01-01"))
      }
      df &lt;- rbind(df, df1)    
    }else
    {
      print("Error: User not found!")
    }
  </code></pre>