<p>Pretty sure PHP is interpreting that string as an <code>int</code>. Doing a <code>var_dump</code> on the variable shows <code>int(596249628892364800)</code>. That's pretty much PHP's type casting at work.</p>

<p>While you could cast the variable as a string, there's actually an unused variable called <code>id_str</code> which is ideal to use.</p>

<p>Edit the file <code>twitter\fieldtypes\Twitter_TweetFieldType.php</code>. Replace line 48 from: </p>

<pre><code>$url = 'https://twitter.com/'.$tweet['user']['screen_name'].'/status/'.$tweet['id'];
</code></pre>

<p>To:</p>

<pre><code>$url = 'https://twitter.com/'.$tweet['user']['screen_name'].'/status/'.$tweet['id_str'];
</code></pre>

CC BY-SA 3.0
2015-05-07T14:01:44.543Z
Thanks crawf, this must be pretty close to the solution.. But the result is still the same. It seems the conversion to float, has already happened before that line, so after grabbing it out of the db.. Not sure where this happens though.
tom
CC BY-SA 3.0
2015-05-07T14:03:39.997Z
Hmm - are you able to do a `var_dump($tweet['id']);` around line 46? And that still prints out the float value?
crawf
CC BY-SA 3.0
2015-05-07T14:20:46.243Z
Actually - just updated my answer using an existing field in that `$tweet` array!
crawf
CC BY-SA 3.0
2015-05-07T16:13:35.397Z
great, now it's working perfectly. Can you tell me where you found this id_str existence? I can't find it anywhere
tom
CC BY-SA 3.0
2015-05-07T23:14:01.633Z
Awesome! I basically just used `var_dump($tweet)` to see what the object was containing. It has a `id` and `id_str` attribute, among many other things.
crawf
CC BY-SA 3.0
2015-05-08T09:31:16.903Z
Thanks. In case anyone else is having this issue; using the `id_str` instead of `id` also works to fix this this issue on the front-end templates.
tom
CC BY-SA 3.0
2015-05-07T12:58:56.853Z
2015-05-08T15:18:00.967Z
2015-05-08T15:18:00.967Z
crawf
<p>I'm using the dukt.net Twitter plugin, in a Matrix field. It works fine locally, but on our dev server, something odd is happening, when I enter a Tweet url, like: </p>

<pre><code>https://twitter.com/POLITICOEurope/status/596249628892364800
</code></pre>

<p>It fetches the tweet from the API correctly, but then displays it in the CP and in the templates as: </p>

<pre><code>https://twitter.com/POLITICOEurope/status/5.96249628892E+17
</code></pre>

<p>So it converts it to a float. However, in the "fields_tweets_tweet" field in the database, it lists the correct long ID: 596249628892364800</p>

<p>And the odd thing is that it's happening on the dev server, but not locally. Anyone an idea where to start?</p>

<plugins><plugin-dukttwitter>
Dukt Twitter plugin float issue
# Dukt Twitter plugin float issue

(Asked by: username_0 on 2015-05-07)

I'm using the dukt.net Twitter plugin, in a Matrix field. It works fine locally, but on our dev server, something odd is happening, when I enter a Tweet url, like: 
https://twitter.com/POLITICOEurope/status/596249628892364800

It fetches the tweet from the API correctly, but then displays it in the CP and in the templates as: 
https://twitter.com/POLITICOEurope/status/5.96249628892E+17

So it converts it to a float. However, in the "fields_tweets_tweet" field in the database, it lists the correct long ID: 596249628892364800
And the odd thing is that it's happening on the dev server, but not locally. Anyone an idea where to start?

**Tags:** plugins, plugin-dukttwitter


---

## 1 answers

### Answer by username_1 on 2015-05-07. Score: 2 | Accepted answer

Pretty sure PHP is interpreting that string as an int. Doing a var_dump on the variable shows int(596249628892364800). That's pretty much PHP's type casting at work.
While you could cast the variable as a string, there's actually an unused variable called id_str which is ideal to use.
Edit the file twitter\fieldtypes\Twitter_TweetFieldType.php. Replace line 48 from: 
$url = 'https://twitter.com/'.$tweet['user']['screen_name'].'/status/'.$tweet['id'];

To:
$url = 'https://twitter.com/'.$tweet['user']['screen_name'].'/status/'.$tweet['id_str'];

> **Comments:**
> **username_0**: Thanks username_1, this must be pretty close to the solution.. But the result is still the same. It seems the conversion to float, has already happened before that line, so after grabbing it out of the db.. Not sure where this happens though.  
> **username_1**: Hmm - are you able to do a `var_dump($tweet['id']);` around line 46? And that still prints out the float value?  
> **username_1**: Actually - just updated my answer using an existing field in that `$tweet` array!  
> **username_0**: great, now it's working perfectly. Can you tell me where you found this id_str existence? I can't find it anywhere  
> **username_1**: Awesome! I basically just used `var_dump($tweet)` to see what the object was containing. It has a `id` and `id_str` attribute, among many other things.  
> **username_0**: Thanks. In case anyone else is having this issue; using the `id_str` instead of `id` also works to fix this this issue on the front-end templates.  

---

