# How to get records from Kintone app into my localhost php program

**URL:** <https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330>\
**Category:** General\
**Created:** [July 14, 2020, 12:27am UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330 "2020-07-14T00:27:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 14, 2020, 12:27am UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/1 "2020-07-14T00:27:25Z")

</div>

I am using OAUTH clients. In one of my php page I set a link and set this as href

| https://{subdomain}.kintone.com/oauth2/authorization |  
| &nbsp; | ?client\_id={your\_client\_id}&redirect\_uri={your\_redirect\_url}&state=state1&response\_type=code&scope=k%3Aapp\_record%3Aread |

I set my redirect\_uri as [http://localhost/kintone.php](http://localhost/kintone.php). When I click on this link, I get an error saying “The redirect\_uri parameter is not valid”. I also see a code and id values on the same page. What could be the error, can anyone please point it out to me.&nbsp;

Thanks

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 15, 2020, 11:04pm UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/2 "2020-07-15T23:04:06Z")

</div>

Hello Hima,

Have you filled out the redirect endpoint on the kintone side?

The setting is at the following:

https://(subdomain).kintone.com/admin/oauth/client/add

Also, to let you know, the URI needs to be in the “HTTPS” protocol,

so can you check that out in case if you already did set up the redirect endpoint on the kintone side?

Kintone Developer Program - How to add OAuth clients

[https://developer.kintone.io/hc/en-us/articles/360001562353-How-to-add-OAuth-clients](https://forum.kintone.dev/hc/en-us/articles/360001562353-How-to-add-OAuth-clients)

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 16, 2020, 8:23pm UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/3 "2020-07-16T20:23:47Z")

</div>

No, I was setting the redirect\_uri to my localhost. I set the redirect\_uri as [https://localhost/display\_records.php](https://localhost/display_records.php). I want to get the authentication code and then want to get the records from a Kintone app and display on my php page. Here is the scenario.&nbsp;

1. I want to create a php page to have a form, which is accessible to public, once the form is submitted, I want to get the data and put it into kintone app.&nbsp;

2. I want to read from that kintone app and display all the data onto my php page, which should be public.

How to achieve this please?

I am trying to use curl\_get() in php as well, but it still complains wrong redirect\_uri. Please help.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 17, 2020, 9:50pm UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/4 "2020-07-17T21:50:41Z")

</div>

Hello Hima,

&nbsp;

As you mentioned in your first post,

&nbsp;

\>I also see a code and id values on the same page.

&nbsp;

Could you please send us that error code and the ID value?

I will be glad to help.

&nbsp;

Thanks,

Sean

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 20, 2020, 5:33pm UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/5 "2020-07-20T17:33:14Z")

</div>

Hi Sean,

Here is the error that I see, with code and id values.&nbsp;

Also I noticed that this time when I run the code, it takes me to login screen after I login it fails with this error.

In my Kintone account I created an OAuth client under Integrations. I also set myself as allowed user. When I click on my name in my account settings under Integrations tab, I notice that against this OAuth Client it shows my status as “Inactive”. Could that be the reason for it to take me to the login page? How to set it to Active?

Any help on this is greatly appreciated. I also attached my code at the bottom.

![](https://developer.kintone.io/hc/user_images/Znet6hiZd35uDt5S2wr_cA.png)

&nbsp;

\<?php  
If(!isset($\_GET[‘code’]))  
{  
//Initialize a CURL session  
$ch=curl\_init();

//From URL to get webpage contents  
$url=“https://{sudomain\_name}.kintone.com/oauth2/authorization?client\_id={Client\_ID}&redirect\_uri=http%3A%2F%2Flocalhost%2Fcurlget.php&state=state1&response\_type=code&scope=k%3Aapp\_record%3Aread”;

curl\_setopt($ch, CURLOPT\_POST, 1);

//grab URL and pass it to the variable  
curl\_setopt($ch, CURLOPT\_URL, $url);

curl\_setopt($ch, CURLOPT\_RETURNTRANSFER,1);

//Execute and get result  
$result = curl\_exec($ch);  
if(!$result)  
{  
die(“Connection Failure”);  
}  
else  
{  
echo $result;  
}  
curl\_close($ch);  
}  
else  
{  
echo $\_GET[‘code’];  
}

?\>

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 21, 2020, 10:59pm UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/6 "2020-07-21T22:59:04Z")

</div>

Hey Hima,

\> I notice that against this OAuth Client it shows my status as “Inactive”.

This is possibly the reason why you see the error upon logging in.  
You should be able to change between active and inactive by clicking on the button  
next to the “Set allowed users” for the client.

But I assume that’s not possible, I guess?  
Can I see how the setting page looks on your side?

![](https://developer.kintone.io/hc/user_images/4-dQRske05fK99BrRnNXUQ.png)

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 23, 2020, 5:45pm UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/7 "2020-07-23T17:45:51Z")

</div>

Hello Hima,

&nbsp;

It depends on the setting on the OAuth side, so it is difficult to determine the error just by looking at the code at the moment  
but, the “http” protocol was specified in redirect\_uri.

&nbsp;

```
redirect_uri=http%3A%2F%2Flocalhost%2Fcurlget.php

```

&nbsp;

A URL starting with “http” is specified, but since only “https” can be specified as a redirect endpoint for OAuth authentication.  
So, the error might be caused by that.

&nbsp;

Also, I do not entirely understand the part,  
\>When I click on my name in my account settings under Integrations tab, I notice that against this  
\>OAuth Client it shows my status as “Inactive”. Could that be the reason for it to take me to the login page?  
\>How to set it to Active?

&nbsp;

Could you please check the following for us?

・Does the URL specified in the redirect\_url match the URL specified in the redirect endpoint of OAuth authentication?  
If not, please match it.

・If the OAuth client is not available; please check if it is enabled by clicking on it.  
If not, please send the screenshot of the “Inactive” screen to see the current status.

・Please, send us a screenshot of your Add OAuth Client settings screen.

&nbsp;

Hopefully, this helps.

Sean

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [July 27, 2020, 10:30pm UTC](https://forum.kintone.dev/t/how-to-get-records-from-kintone-app-into-my-localhost-php-program/330/8 "2020-07-27T22:30:53Z")

</div>

Thank you Sean and Yuzo for responding promptly. Actually I found this resource and this worked.&nbsp;

[https://github.com/ochi51/cybozu-http](https://github.com/ochi51/cybozu-http)

The below given part is not clear in the documentation as to where to put the line of code. I tried to do it with composer but it threw me error. Later I found out after many attempts that this line of code will go into your trial php program file, just above the quick start piece of code. I hope this helps anyone else who is trying to attempt api calls with PHP.

After installing, you need to require Composer’s autoloader:

```
require 'vendor/autoload.php';
```
