Can't get a value from an URL parameter - http

I'm trying to integrate the Google+ API in my web application which is developed in Angular2 so I can login to the home page using my Google account credentials and without the need to create a new account. I made a clickable html link that has the following href
https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=**********.apps.googleusercontent.com&scope=email&redirect_uri=http://localhost:3000/home
Once clicking on it, it demands for permission through my google account and when i authorize, it redirect me to the http://localhost:3000/home?code=4 the problem is that I need the whole code's value so that I can use it to get the Access Token but I don't know why the value appeared then it went hidden in less than a second and just keeping the first letter of the code (which is 4 in this case). The problem that if I go back to the previous page of the browser it will appear again.
Any help please? Or Is there any Function in Angular2 that tells the browser to go back to the previous page so I can get the whole code ?

Related

LinkedIn Profile Image missing on Authentication from App

I use REST API to share articles/posts on LinkedIn Timeline and Company pages. To do so, I authorize my LI profile with the APP for accessing the profile info. As a result, could view the profile/image of a user in the APP. Everything worked fine until, for some time now, aren't able to view the user profile image from the APP. Now, it looks like:
Previous image URL starts with(accessible): https://media.licdn.com/mpr/mprx/0_
Current image URL starts with(could not access): https://media.licdn.com/dms/image/
On accessing the image in the browser,
Help me understand what has changed with LI. Thanks.
Are you injecting the URL in same way that's escaping it? The URL recently changed and has some characters that templating engines such as Handlebars will mistakenly escape.
If you inject the URL without escaping it, it should work just fine.
Check out this documentation. https://developer.linkedin.com/docs/ref/v2/media-migration,
The problem which I was facing was the image loaded sometimes, but after some days it would give above error.
The new id will be dynamic and can change from time to time. We recommend retrieving at least once every 60 days to update your media-typed URN.
In order to fix this, I save the image, the moment it is received on to personal storage(AWS S3).

Show list of pages that are opened at the time being

I have a task to list all pages which are opened at that moment and show how many people are on that page.
I am looking for a way to make that happen without keeping any db records or saving information on a text file or smth like that. (Not seccessarily, then. Of course I am going to save that info to a dB, I just wanted to the logic of catching opened page addresses.)
I can of course keep track of every page which are opened till that time, but I want the page address appear on the page when someone opens that address and disappear when user is no longer browsing that address.
Can you give me some ideas how to make that happen using ASP.NET?
Note: I am using web forms with asp.net 4.5
Thanks!
"I just wanted to the logic of catching opened page addresses"
Use javascript in a timed loop (onload and then every 30 seconds perhaps) on every page, to asynchronously post to a page on your server. It should send information identifying the page. This will give you a good idea of how many people currently are on this page.
Store this information in a db in your code-behind, and use this information to report as you wish.
Of course if a user leaves their browser open on one of these pages or opens another tab it will still be reporting as 'open'.
To get the current url in javascript you can use:
var pathname = window.location.pathname;
In google analytics you can see what pages are being used in near-real time.
Why not use that to solve this issue - it's easy to setup.

Correct way to link to new page in canvas page app php-sdk

I'm running in to a couple of issues and wondered if anyone had any insight. I'm using the latest php-sdk I'm developing a canvas app that has a number of different steps. These steps are spread across multiple pages. Now when I first enter the app everything seems to work fine. The access token is there and I can call the api functions. On the second page (which is linked to in the same iframe) I get OAuth errors. Now if I use this on the 2nd page:
$me = $facebook->getUser();
var_dump($me);
it returns the correct user id, but I still get errors when trying to use an api query (specifically a FQL one in this instance)
Now, bear in mind these links are within the iframe so I was assuming the signed_request is getting lost somewhere, I know facebook normally issues this via a POST. If I set all my links to target="_parent" with a url such as http://apps.facebook.com/myapp/page2.php then everything works fine. Facebook clearly posts the correct info this time. Subsequently, then when I use links that only redirect the iframe it seems to work fine again (implying a cookie is being set somewhere).
Now I've seen other apps that don't have a target="_parent" that seem to work correctly, only ever loading the iframe on subsequent clicks and not the full facebook site. So I can only assume they are storing this info somewhere. I've tried to inspect these apps using httpfox but I can't see anything obvious. Does anyone have any links for best practice with multiple page apps? I know I can get around this using full urls and target="_blank" but I would like to know what's going on here. I've looked through the developer docs and the canvas page examples, but there's nothing obvious to me.
Any help or info would be appreciated
Many Thanks
There is some ways to achieve this
using Facebook JavaScript SDK (which will set cookie for you, so PHP-SDK can rely on it)
issuing POST request to your pages including signed_request from initial page loaded in canvas

sharing my page URL on twitter via twitter share button

I have a problem using twitter share button on my asp.net page.The problem is that when I click on the share button i want it to share the URL of my page which the share button exists for example "http://localhost:1349/Pages/Share/ShareRedeemtion.aspx?UID=2&GiftID=1&MID=2 via#QhatAPP" but for some reason which i can't figure the button only share the title of the page, I'm confused is there is a problem with twitter share button to share URLs which contains a query string? and if do exists a problem is there any way enables me to share my URL on twitter via twitter share button?
You appear to have 2 problems:
You need to encode the URL you are passing in because, yes, it has a querystring on it. Check out URLEncode if you need to.
It also doesn't appear to work with non-publicly accessible Urls (your localhost in the sample). It may be doing some sort of callback to check that the Url is accessible or checking for Spam.
A sample that works with a querystring.
https://twitter.com/share?url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F8190644%2Fsharing-my-page-url-on-twitter-via-twitter-share-button%3Ftemp%3D1&text=Test+Link
For more information and properties for the button, check https://dev.twitter.com/docs/tweet-button

iframed ASP actions trouble

This is actually a follow up on my previous question (link)
I've created the HttpHandler and it works fine for now, I'll add flexibility by using the querystring and session to point the post I'm making in the right direction.
The next question is as follows.
Now that I have the old page iframed as it should be, there's still the trouble of handling the postbacks (or actions) these pages trigger.
Every button action (asp form post) refers to a page that is not there (it's on the other server from which I am importing functionality).
I've tried using a url mapping to the other server but I get an error that tells me the external link is not a valid virtual directory. Hence I discarded this option.
I there anyway to keep functionality going inside the iframe?
please do ask clarification if you need it.
I got a solution from a colleague.
before passing the response string to the Iframe from the handler I use a string.replace to adjust the urls in the old site. This way they point to the old site and everything works again :)

Resources