How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask ATLPROG Your Own Question

ATLPROG
ATLPROG, Computer Software Engineer
Category: Programming
Satisfied Customers: 7677
Experience:  MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
44910485
Type Your Programming Question Here...
ATLPROG is online now
A new question is answered every 9 seconds

I am very new to php. The code I have written is pulling a

Customer Question

I am very new to php. The code I have written is pulling a list of users from a web site. I need to be able to traverse the list to pull out only certain fields. I do not understand how to do that. The code snippet is below.
for($i = 0; $i 100,
'offset' => $i);
$accessRequest = OAuthRequest::from_consumer_and_token($consumerObject, $tokenObject, "GET", $endpoint, $params);
$accessRequest->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumerObject, $tokenObject);
$ch = curl_init($accessRequest->to_url());
//Return curl_exec results as string return value
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_CAINFO, "c:/wamp/cacert.pem");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, false);
$yardusers = json_decode(curl_exec($ch));
curl_close($ch);
foreach($yardusers->members as $yardmember)
{
print_r($yardmember);
$counter++;
}
}
Submitted: 10 months ago.
Category: Programming
Expert:  The-PC-Guy replied 10 months ago.

i'm not following don't you just have a mysql database that has all the tables in it? Why go through curl?

Expert:  The-PC-Guy replied 10 months ago.

there are several problems with the code, but I will need more information before we can proceed

Customer: replied 10 months ago.
Keep me a min. No there is not database. The information is returned from the website. Let me remove the security info and I will post all the code. Here is the code. The "hello" stuff in the beginning was just to make sure I was actually getting something back.
PHP Test
<?php
echo '

Hello World

';
echo "

Current date and time: " . date("r") . "

";
echo "

Let's Test Connect Yard Connection " . date("r") . "

";//Add OAuth Files
include 'c:\wamp\www\MyFiles\OAuth.php';//FILL IN YOUR OAUTH INFORMATION
$key = 'foo';
$secret = 'foo';
$token = 'foo';
$token_secret = 'foo';
//USING FLOW 1: OVERRIDE User Id - each endpoint requires an override user id
$overrideUserId = '12345';
$TheYardID = '99999';
$consumerObject = new OAuthConsumer($key, $secret, NULL);
$tokenObject = new OAuthConsumer($token, $token_secret);$endpoint = "https://api.xx.com/v1/yards/" .$TheYardID. "/reports?overrideUserId=" . $overrideUserId;
$accessRequest = OAuthRequest::from_consumer_and_token($consumerObject, $tokenObject, "GET", $endpoint, array());
$accessRequest->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumerObject, $tokenObject);$ch = curl_init($accessRequest->to_url());//Return curl_exec results as string return valuecurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_CAINFO, "c:/wamp/cacert.pem");
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$yardInfo = json_decode(curl_exec($ch));
$yardMemberCount = $yardInfo->numMembers;curl_close($ch);
print '
------------------------ Yard Members: '.$yardMemberCount.' ------------------------
';
$counter = 1;$endpoint = "https://api.connectyard.com/v1/yards/" .$TheYardID. "/users?overrideUserId=" . $overrideUserId;
for($i = 0; $i <= $yardMemberCount; $i+=100)
{
$params = array(
'count' => 100,
'offset' => $i);$accessRequest = OAuthRequest::from_consumer_and_token($consumerObject, $tokenObject, "GET", $endpoint, $params);
$accessRequest->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumerObject, $tokenObject);
$ch = curl_init($accessRequest->to_url());//Return curl_exec results as string return valuecurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_CAINFO, "c:/wamp/cacert.pem");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, false);
$yardusers = json_decode(curl_exec($ch));curl_close($ch);foreach($yardusers->members as $yardmember)
{
print_r($yardmember);
$counter++;
}}
?>
Expert:  The-PC-Guy replied 10 months ago.

i may need to see the oauth.php file.

would be easier if you would zip the appropriate files, and upload the zip file

to

www.wikisend.com

after uploading they give you a download link.

paste that link here. then please answer these questions.

1. What is the goal?

2. What type of output is the server request returning, can I assume since you are using json_decode, that it is returning a json file?

3. I would need to see the output of that json file. Or the output from the curl exec.?

perhaps, it might be best to do some kind of remote support. There will be an additional charge for that, but I think it will save hours worth of work.

Customer: replied 10 months ago.
Gimme a min. Here is a .txt of the oauth file.
Expert:  The-PC-Guy replied 10 months ago.

can you answer the above questions?

Or would it be easier to do a remote session and we can chat and make modifications in real time.

Which I think would be way easier.

Customer: replied 10 months ago.
the output is json from $yardusers - json_decode(curl_exec($ch));
Here is a snippet of the output. There are over 2k members, 2469 actually.
stdClass Object ( [id] => 929206 [name] => Aaron Black [primaryMail] =>***@******.*** [picture_url] => https://s3.amazonaws.com/connectyard-static/images/user_v1.png [role] => member [status] => enabled ) stdClass Object ( [id] => 720775 [name] => Aaron Cline [primaryMail] =>
Customer: replied 10 months ago.
I want to read the output locate just id, name, primaryemail and store that in an oracle data locally.
Expert:  The-PC-Guy replied 10 months ago.

i cant help you with the oracle stuff.

But if you want to set up a remote session I may be able to help with parsing the output.

I do keep pushing for remote, just because I think it will save a lot of time and be easier.

But if you are not comfortable with that we will try to slug through it here.

Customer: replied 10 months ago.
I don't need help with the oracle stuff, got that covered. Remote save more time but I am on a limited budget.
Expert:  The-PC-Guy replied 10 months ago.

tell you want, ill do the remote for an additional $60. Hopefully that will be within your budget

Customer: replied 10 months ago.
I am willing to go $62, that's about it.
Expert:  The-PC-Guy replied 10 months ago.

well good luck to you

Expert:  The-PC-Guy replied 10 months ago.

if you change your mind you know how to reach me

Customer: replied 10 months ago.
That is not in your advertisement at all. I think we are done. I will expect a $5.00 charge, no more.