返回两个用户关系的详细情况

如果源用户或目的用户不存在，将返回http的400错误
<br />对应API：{@link http://open.weibo.com/wiki/2/friendships/show friendships/show}

@access public
@param mixed $target_name 目标用户的微博昵称
@param mixed $source_name 源用户的微博昵称，可选，默认为当前的用户
@return array
196045
function is_followed_by_name( $target_name, $source_name = NULL )
	{
		$params = array();
		$params['target_screen_name'] = $target_name;

		if ( $source_name != NULL ) {
			$params['source_screen_name'] = $source_name;
		}

		return $this->oauth->get( 'friendships/show', $params );
	}
555840
public function map($source, &$target)
    {
        $source = static::makeSource($source);
        $writer = static::makeWriter($target);

        foreach ($this->fields as $field) {
            try {
                $writer::set($target, $field->getName(), $field->getDefinition()->getValue($source));
            } catch (SourceFieldMissingException $e) {
                if ($this->ignoreAllMissing) {
                    continue;
                }
                throw $e;
            } catch (IgnoreFieldException $e) {
                continue;
            }
        }
    }
506191
public function trigger($name, $data = [], $target = null, $paramClass = EventParam::class)
    {
        // ClassEventListener支持
        $callbacks = $this->getTriggerCallbacks($name);
        // 实例化参数
        $param = new $paramClass($name, $data, $target);
        $hasOne = false;
        foreach($callbacks as $callback)
        {
            // 事件配置
            if(isset($this->events[$name]))
            {
                $option = $this->events[$name]->offsetGet($callback);
            }
            // 回调类型处理，优先判断为类的情况
            $type = 'callback';
            if(is_string($callback) && class_exists($callback))
            {
                $type = 'class';
            }
            // 回调执行
            switch($type)
            {
                case 'callback':
                    call_user_func_array($callback, [$param]);
                    break;
                case 'class':
                    $obj = BeanFactory::newInstance($callback);
                    call_user_func_array([$obj, 'handle'], [$param]);
                    break;
            }
            // 仅触发一次
            if(isset($option['one']) && $option['one'])
            {
                $this->events[$name]->detach($callback);
                $hasOne = true;
            }
            // 阻止事件传播
            if($param->isPropagationStopped())
            {
                break;
            }
        }
        // 仅触发一次的处理
        if($hasOne)
        {
            $this->eventChangeRecords[$name] = true;
        }
    }
1040566
public function getIndexes ($table_name, $forced_obtain = false) {
		if (!isset(array_flip($this->getTables($forced_obtain))[$table_name])) {
			throw CoreException::RaiseSystemError('存在しないテーブルを指定されました。table_name:%s', [$table_name]);
		}
		if ($forced_obtain || !isset($this->_indexes[$table_name])) {
			$this->_updateIndexes($table_name);
		}
		return $this->_indexes[$table_name];
	}
508116
protected function getRelationAttribute($name, &$item)
    {
        $relation = $this->isRelationAttr($name);

        if ($relation) {
            $modelRelation = $this->$relation();
            if ($modelRelation instanceof Relation) {
                $value = $this->getRelationData($modelRelation);

                if ($item && method_exists($modelRelation, 'getBindAttr') && $bindAttr = $modelRelation->getBindAttr()) {

                    foreach ($bindAttr as $key => $attr) {
                        $key = is_numeric($key) ? $attr : $key;

                        if (isset($item[$key])) {
                            throw new Exception('bind attr has exists:' . $key);
                        } else {
                            $item[$key] = $value ? $value->getAttr($attr) : null;
                        }
                    }

                    return false;
                }

                // 保存关联对象值
                $this->relation[$name] = $value;

                return $value;
            }
        }

        throw new InvalidArgumentException('property not exists:' . static::class . '->' . $name);
    }
1275858
private function parseSource()
    {
        if (null == $this->contactSource) {
            // Check Source existence and published status.
            $this->contactSource = $this->contactSourceModel->getEntity($this->sourceId);
            if (!$this->contactSource) {
                throw new ContactSourceException(
                    'The sourceId specified does not exist.',
                    Codes::HTTP_NOT_FOUND,
                    null,
                    Stat::TYPE_INVALID,
                    'sourceId'
                );
            } elseif (false === $this->contactSource->getIsPublished()) {
                throw new ContactSourceException(
                    'The sourceId specified has been unpublished (deactivated).',
                    Codes::HTTP_GONE,
                    null,
                    Stat::TYPE_INVALID,
                    'sourceId'
                );
            }
            $this->addTrace('contactSourceId', (int) $this->sourceId);
        }

        return $this;
    }
723494
protected static function mergeArrays($target, $source)
    {
        foreach ($source as $node => $values) {
            if (!array_key_exists($node, $target)) {
                $target[$node] = $values;
            } elseif (is_array($values)) {
                $target[$node] = self::mergeArrays($target[$node], $values);
            } else {
                $target[$node] = $values;
            }
        }

        return $target;
    }
757653
private function findFriendshipsByStatus($status, $limit, $offset): array
    {
        $friendships = [];

        $query = Friend::where(function ($query) use ($status) {
            $query->where('sender_id', $this->id);
            $query->where('sender_type', get_class($this));

            if (!empty($status)) {
                $query->where('status', $status);
            }
        })->orWhere(function ($query) use ($status) {
            $query->where('recipient_id', $this->id);
            $query->where('recipient_type', get_class($this));

            if (!empty($status)) {
                $query->where('status', $status);
            }
        });

        if (!empty($limit)) {
            $query->take($limit);
        }

        if (!empty($offset)) {
            $query->skip($offset);
        }

        foreach ($query->get() as $friendship) {
            $friendships[] = $this->getFriendship($this->find(
                ($friendship->sender_id == $this->id) ? $friendship->recipient_id : $friendship->sender_id
            ));
        }

        return $friendships;
    }
148364
private static function get_all_fields( $target_id = 0 ) {
		$data = [];

		$field_objs = get_field_objects( $target_id );

		if ( $field_objs ) {
			foreach ( $field_objs as $field_name => $field_obj ) {
				$value = self::get_single_field( $target_id, $field_obj );

				$group_slug = self::get_group_slug( $field_obj['parent'] );

				if ( $group_slug ) {
					$data[ $group_slug ][ $field_name ] = $value;
				} else {
					$data[ $field_name ] = $value;
				}
			}
		}

		return $data;
	}
124841
public static function getCookiesFromHeader($header, $source_url)
  {
    $cookies = array();
    
    $hits = preg_match_all("#[\r\n]set-cookie:(.*)[\r\n]# Ui", $header, $matches);
    
    if ($hits && $hits != 0)
    {
      for ($x=0; $x<count($matches[1]); $x++)
      {
        $cookies[] = PHPCrawlerCookieDescriptor::getFromHeaderLine($matches[1][$x], $source_url);
      }
    }
    
    return $cookies;
  }
345809
protected function populateObject($sourceObject, $targetObject, array $targetObjectCtorArgs = array()) {
		if (is_object($targetObject)) {
			$resultObject = $targetObject;
		}
		else {
			$ref = new ReflectionClass($targetObject);
			$resultObject = $ref->newInstanceArgs($targetObjectCtorArgs);
		}

		$ref = new ReflectionClass($sourceObject);
		foreach ($ref->getProperties() as $property) {
			$name=$property->getName();
			$resultObject->$name = $sourceObject->$name;
		}

		return $resultObject;
	}
326237
public function createNew(
        int $sourceId,
        string $name,
        $value,
        $type = null
    ) : array {
        if ($type === null) {
            $type = $this->typeInfer($value);
        }

        return $this->sendPost(
            sprintf('/profiles/%s/features', $this->userName),
            [],
            [
                'source_id' => $sourceId,
                'name'      => $name,
                'value'     => $value,
                'type'      => $type
            ]
        );
    }
940747
static ImmutableList<ListFindingsResult> listFindingsWithQueryMarks(SourceName sourceName) {
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
      // Start setting up a request for to list all findings filtered by a specific security mark.
      // SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/
      // "423432321");

      String filter = "NOT security_marks.marks.key_a=\"value_a\"";

      ListFindingsRequest.Builder request =
          ListFindingsRequest.newBuilder().setParent(sourceName.toString()).setFilter(filter);

      // Call the API.
      ListFindingsPagedResponse response = client.listFindings(request.build());

      // This creates one list for all findings in the filter.If your organization has a large
      // number of
      // findings this can cause out of memory issues.  You can process them batches by returning
      // the Iterable returned response.iterateAll() directly.
      ImmutableList<ListFindingsResult> results = ImmutableList.copyOf(response.iterateAll());
      System.out.println("Findings with security mark - key_a=value_a:");
      System.out.println(results);
      return results;
    } catch (IOException e) {
      throw new RuntimeException("Couldn't create client.", e);
    }
  }
973029
public function create_group($group_name)
    {
        $url = self::API_DOMAIN . 'cgi-bin/groups/create?access_token=' .$this->get_access_token();
        $xml = sprintf('{"group":{"name":"%s"}}', $group_name);
        $res = HttpCurl::post($url, $xml, 'json');
        // 异常处理: 获取时网络错误
        if ($res === false) {
            return Error::code('ERR_POST');
        }
        // 判断是否调用成功
        if (isset($res->group)) {
            return array(null, $res);
        } else {
            return array($res, null);
        }
    }
71175
public function nearByName(string $name, $radius, int $limit = 10, string $order = 'asc'): array
    {
        $ret = $this->handle->rawCommand('getradiusbymember', [$name, $radius, 'm', 'withcoord', 'withdist', $order, 'count', $limit]);

        //可能需要转换格式
        return $ret;
    }
520882
public static function get($key, $config_name = 'main')
    {
        // 获取值
        // 加载其他配制文件
        if ($config_name !== 'main' && !isset(self::$_config[$config_name])) {
            $filename = APP_PATH . '/conf/' . $config_name . '.php';
            if (file_exists($filename)) {
                self::$_config[$config_name] = include $filename;
            } else {
                \show_error("Config file {$filename} is not exists.");
            }
        }

        // 返回需要value
        if ($key === '') {
            return self::$_config[$config_name];
        } elseif (array_key_exists($key, self::$_config[$config_name])) {
            return self::$_config[$config_name][$key];
        } elseif (strpos($key, '.')) {
            $array = explode('.', $key);
            if (count($array) === 2) {
                return isset(self::$_config[$config_name][$array[0]][$array[1]]) ? self::$_config[$config_name][$array[0]][$array[1]] : false;
            } elseif (count($array) === 3) {
                return isset(self::$_config[$config_name][$array[0]][$array[1]][$array[2]]) ? self::$_config[$config_name][$array[0]][$array[1]][$array[2]] : false;
            } else {
                show_error('Config::get("a.b.c") Only 3 levels are allowed.');
            }
        } else {
            return false;
        }
    }
915827
public function actionSearch($id, $target, $term = '')
    {
        Yii::$app->response->format = 'json';
        $authManager = Yii::$app->authManager;
        $roles = $authManager->getRoles();
        $permissions = $authManager->getPermissions();

        $avaliable = [];
        $assigned = [];
        foreach ($authManager->getAssignments($id) as $assigment) {
            if (isset($roles[$assigment->roleName])) {
                if (empty($term) || strpos($assigment->roleName, $term) !== false) {
                    $assigned['Roles'][$assigment->roleName] = $assigment->roleName;
                }
                unset($roles[$assigment->roleName]);
            } elseif (isset($permissions[$assigment->roleName]) && $assigment->roleName[0] != '/') {
                if (empty($term) || strpos($assigment->roleName, $term) !== false) {
                    $assigned['Permissions'][$assigment->roleName] = $assigment->roleName;
                }
                unset($permissions[$assigment->roleName]);
            }
        }

        if ($target == 'avaliable') {
            if (count($roles)) {
                foreach ($roles as $role) {
                    if (empty($term) || strpos($role->name, $term) !== false) {
                        $avaliable['Roles'][$role->name] = $role->name;
                    }
                }
            }
            if (count($permissions)) {
                foreach ($permissions as $role) {
                    if ($role->name[0] != '/' && (empty($term) || strpos($role->name, $term) !== false)) {
                        $avaliable['Permissions'][$role->name] = $role->name;
                    }
                }
            }
            return $avaliable;
        } else {
            return $assigned;
        }
    }