Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6843903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:18:33+00:00 2026-05-27T00:18:33+00:00

I am coding a site in PHP that will allow a user to view

  • 0

I am coding a site in PHP that will allow a user to view all his Google Contacts’ names and profile photos in one long list. Then the user can drag-n-drop new photos to replace the existing profile photos.

However, I’m getting a 401 (unauthorized access) error when trying to update the photos.

I know the access_token is correct because it works in GET requests such as https://www.google.com/m8/feeds/photos/media/default/6f2?access_token=ya29.AHES6ZR_ZS7_u-8TbMOMaeaGW9q4F7tkuPxW6gFTulyBX

The docs have not helped much. See also these and these.

My code looks something like:

#the stuff that i echo out is just for debugging purposes
$apiVersion='3.0';
$access_token = $this->session->userdata('googleauth_access_token');

$url = 'https://www.google.com/m8/feeds/photos/media/default/' . $contactID;
$fp = fopen($image_location, "r");
$filesize = filesize($image_location);
echo '<img src="https://www.google.com/m8/feeds/photos/media/default/'. $contactID. '?access_token=' . $access_token.'"/><br/>';    
echo $image_location;
echo $filesize;
echo $url;
$requestHeaders=array('Content-type: image/*','If-Match: '.$eTag,'GData-Version: '.$apiVersion);
$requestHeaders[]='Authorization: Bearer '. $access_token;
print_r($requestHeaders);
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_PUT, true);
curl_setopt($c, CURLOPT_INFILESIZE, $filesize);
curl_setopt($c, CURLOPT_INFILE, $fp);
curl_setopt($c, CURLOPT_VERBOSE, true);
curl_setopt($c, CURLOPT_HTTPHEADER, $requestHeaders);
$result = curl_exec($c);    
$curlGetInfo=curl_getinfo($c);
print_r($curlGetInfo);
curl_close($c);
fclose($fp);
echo $result;

I have also tried variations such as replacing the 'Authorization: Bearer' line with Authorization: GoogleLogin auth=ya29.AHES6ZR_ZS7_u-8TbMOMaeaGW9q4F7tkuPxW6gFTulyBX

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:18:34+00:00Added an answer on May 27, 2026 at 12:18 am

    I can’t believe it worked, but changing image/* to image/jpg fixed the 401 error problem.

    (This post tipped me off.)

    Also FYI, I’m still using $requestHeaders[]='Authorization: Bearer '. $access_token; rather than $requestHeaders[]='Authorization: GoogleLogin auth='. $access_token;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm coding a web site and I have a php fonction called site_nav.php which
I am looking for some code that will return me values if the user
I used many different browsers while I was coding for a new site (Firefox,
Coding footer naively, if there's not enough content, then there will be empty space
I am currently investigating a double request problem on my site. Not all the
I'm developing a web site, which would make use of PHP, Javascript (JQuery) and
I've been coding with php/CI for a bit now and am starting to get
Active site can be seen here: http://www.studioimbrue.com/index2.php There are currently two small problems with
Hi I have a web form that sends a string to one php file
What is common practice for coding web applications where part of the site has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.