Send Facebook image url as parameter - php

Facebook image url for user profile looks like
https://scontent.xx.fbcdn.net/hprofile-xfa1/v/t1.0-1/c26.26.321.321/s50x50/1004031_160695494109373_202362495_n.jpg?oh=bc24275f3c0b63adcd7f2
I want to send this url in request to server
$FBImageUrl = "https://scontent.xx.fbcdn.net/hprofile-xfa1/v/t1.0-1/c26.26.321.321/s50x50/1004031_160695494109373_202362495_n.jpg?oh=bc24275f3c0b63adcd7f2";
$postString = "http://example.com/script.php?img_url=" . FBImageUrl;
But what will happen if this url have question mark inside?

use urlencode()
$FBImageUrl = "https://scontent.xx.fbcdn.net/hprofile-xfa1/v/t1.0-1/c26.26.321.321/s50x50/1004031_160695494109373_202362495_n.jpg?oh=bc24275f3c0b63adcd7f2";
$postString = "http://example.com/script.php?img_url=".urlencode($FBImageUrl) ;
In your script.php
$img_url = urldecode($_GET['img_url']);

You need to urlencode your parameter.

You can use base64_encode & base64_decode. Also for security reasons image URL wont be visible in the address bar.
$FBImageUrl = "https://scontent.xx.fbcdn.net/hprofile-xfa1/v/t1.0-1/c26.26.321.321/s50x50/1004031_160695494109373_202362495_n.jpg?oh=bc24275f3c0b63adcd7f2";
$base64Url = base64_encode($FBImageUrl);
$postString = "http://example.com/script.php?img_url=" . $base64Url;
Receiver you can decode it
$fbUrl = base64_decode($_GET['img_url']);

Related

I can't get value in URL | PHP

URL ex: gamob.net/token?#access_token=EAAKJnZAm
Code PHP:
eg 1:
$token = $_GET['access_token'];
echo $token;
eg 2:
$token = $_GET['#access_token'];
echo $token;
eg 3:
$token = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
echo $token;
All can't get value in Url. Thank you!
I think the char # is reserved to mark anchor.
I have never seen it in GET parameters
try this ex url : gamob.net/token?access_token=EAAKJnZAm
And acces the param like that : $_GET['access_token'];
Also ?is to mark the beginning of the params and & separation between parametres
The variable # can only be retrieved by Javascript.
Look this exemple: how to save facebook access token after success

Make a $_GET into variable or place into URL

How do you place a $_GET['****']; into a string or make it into a variable.
For Example i have this url:
http://localhost/PhpProject2/product_page.php?rest_id=3/area=Enfield.
I want to get the area and rest_id from the url. in order to redirect another page to this exact page.
echo"<script>window.open('product_page.php?rest_id= 'put get here'/area='put get here'','_self')</script>";
I have so far done this:
if(isset($_GET['rest_id'])){
if(isset($_GET['rest_city'])){
$_GET['rest_id'] = $rest_id;
}
}
This obviously does not work, so my question is how do i make the 2 $_GET into a variable or call the $_GET into the re-direct string.
What i have tired so far
echo"<script>window.open('product_page.php?rest_id=' . $GET['rest_id'] . '/area='put get here'','_self')</script>";
How or what is the best practice?
ok, first things first. in your URL you have to separate the parameters using an ampersand "&", like this
http://localhost/PhpProject2/product_page.php?rest_id=3&area=Enfield
Also, you have to assign the $_GET value to a variable, not the other way around, like this
$rest_id = $_GET['rest_id'];
so if you create a PHP file named product_page.php and use the url i gave you, and your PHP code looks like this, it should work..
<?php
if (isset($_GET['rest_id'])){
$rest_id = $_GET['rest_id'];
}
if (isset($_GET['rest_id'])){
$area = $_GET['area'];
}
$url = 'other_page.php?rest_id=' . $rest_id . '&area=' . $area;
header("Location: $url");
?>
The question here is why do you want to redirect from this page to the other, and not send the parameters directly to the "other_page.php"????

Post url in form with get method

I have a problem today!
I am trying to post a URL in form via GET method
When I post URL it automatically converts to http://example.com/?url=http%3A%2F%2Fanonylinq.com%2F%3Fi%3Dphpphp from http://anonylinq.com/?i=phpphpIs there any way to solve this problem? I am doing this via PHP.
because I want to echo "i" as - <?php echo $i; ?> Everything else is done but I am stuck at this point.
Already done this too -
$urlSplitted = explode('?i=', $_GET['url']); $i = $urlSplitted[1];
if you want to go this road:
$urlSplitted = explode('?i=', $_GET['url']); $i = $urlSplitted[1];
you should use
$urlSplitted = explode('%3Fi%3D', $_GET['url']); $i = $urlSplitted[1];
Take a look at http://php.net/manual/en/function.urldecode.php
That should do the trick for it.
e.g.
$string = $_GET['url'];
$decoded = urldecode($string);
$urlSplitted = explode('?i=', $decoded );
$i = $urlSplitted[1];
I have done this:
Just made form with post method to other file having meta refresh and echoed url in meta refresh value! Thats it! Meta refresh will not encode your url.

Appending GET parameters on HREF tag with PHP

I'm working on a code like this:
<?php
$id=$_POST['id'];
$url_tag = $_POST['url_tag'];
$url_back = 'https://www.page.example.com/page.php?';
$query='id='.$id.'&url_tag='.$url_tag;
$url = $url_back.$query;
echo 'Look how this url shows up: '.$url;
echo '<a href='.$url.'>Click here</a>';
?>
This is, the page receives two POST parameters. Then prepare a link to https://www.page.example.com/page.php? and I append those two parameters as GET parameters with the ids id and url_tag respectively.
Then I display how the whole link looks like. It shows up correctly, in this case https://www.page.example.com/page.php?id=ID&url_tag=URL_TAG, where ID and URL_TAG are the actual values received as POST parameters.
However, when I click on the 'Click here' link, it redirects me to https://www.page.example.com/page.php?, which is the url without any GET parameter.
Why is that happening and how would I solve it? I've tried to feed HREF with urlencode($url) instead, but it redirects me to an address flooded with undesired characters...
Any idea? Thank you!
Try to replace the last line of your code by this:
echo 'Click here';
It should work.
Try using http_build_query(), it takes care of any URL character compatibility issues for you...
// assuming you've already checked and validated your $_POST parameters
$query = http_build_query(array(
'id' => $_POST['id'],
'url_tag' => $_POST['url_tag']
));
$url = 'https://www.page.example.com/page.php?' . $query;
?>
Click here

Append Var to URL in PHP

I can't seem to get this to work...what I have is a link being auto-generated to send out in an email, and I need to be able to append the user's email address to the URL, but I can't seem to get it formatted correctly. Here's what I have:
href=\"http://example.com/unsubscribe/\" . $email . \"\"
Where the resulting link in the user's email should be
http://example.com/unsubscribe/myemail#myemail.com
The way the unsubscribe is structured, it wants it the above format instead of with ?email=. Can I do this?
EDIT 12/3/13:
Thanks for all the help, guys! Part of my problem is that I wasn't passing the email var through my generate email function. :/
Here's how I ended up setting it up:
$unsubscribeurl = 'http://example.com/unsubscribe/';
$unsubplus = $unsubscribeurl . $email;
$unsubscribelink = 'UNSUBSCRIBE';
Then to set the link up, I just used $unsubscribelink.
Creating the url:
$url = 'http://example.com/unsubscribe/' . urlencode($email);
Creating the link:
$link = 'link';
Using the link in html context:
<?php echo $link ?>
Or:
link
urlencode()
htmlspecialchars()

Categories